@@ -150,6 +150,7 @@ Function Add-VMImage{
150150 }
151151 }
152152
153+ $ArmEndpoint = $ArmEndpoint.TrimEnd (" /" )
153154 $uri = $armEndpoint + ' /subscriptions/' + $subscription + ' /providers/Microsoft.Compute.Admin/locations/' + $location + ' /artifactTypes/platformImage/publishers/' + $publisher
154155 $uri = $uri + ' /offers/' + $offer + ' /skus/' + $sku + ' /versions/' + $version + ' ?api-version=2015-12-01-preview'
155156
@@ -320,6 +321,7 @@ Function Remove-VMImage{
320321 Write-Error - Message (' VM Image with publisher "{0}", offer "{1}", sku "{2}" is not present.' -f $publisher , $offer , $sku ) - ErrorAction Stop
321322 }
322323
324+ $ArmEndpoint = $ArmEndpoint.TrimEnd (" /" )
323325 $uri = $armEndpoint + ' /subscriptions/' + $subscription + ' /providers/Microsoft.Compute.Admin/locations/' + $location + ' /artifactTypes/platformImage/publishers/' + $publisher
324326 $uri = $uri + ' /offers/' + $offer + ' /skus/' + $sku + ' /versions/' + $version + ' ?api-version=2015-12-01-preview'
325327
@@ -371,6 +373,9 @@ function New-Server2016VMImage {
371373
372374 [ValidateNotNullorEmpty ()]
373375 [String ] $TenantId ,
376+
377+ [Parameter ()]
378+ [bool ] $CreateGalleryItem = $true ,
374379
375380 [switch ] $Net35
376381 )
@@ -531,8 +536,15 @@ function New-Server2016VMImage {
531536 try {
532537 Write-Verbose - Message " Creating Server Core Image"
533538 CreateWindowsVHD @ConvertParams - VHDPath $ImagePath - Edition $CoreEdition - ErrorAction Stop - Verbose
534- $description = " This evaluation image should not be used for production workloads."
535- Add-VMImage - sku " 2016-Datacenter-Core" - osDiskLocalPath $ImagePath @PublishArguments - title " Windows Server 2016 Datacenter Core Eval" - description $description
539+ if ($CreateGalleryItem )
540+ {
541+ $description = " This evaluation image should not be used for production workloads."
542+ Add-VMImage - sku " 2016-Datacenter-Core" - osDiskLocalPath $ImagePath @PublishArguments - title " Windows Server 2016 Datacenter Core Eval" - description $description - CreateGalleryItem $CreateGalleryItem
543+ }
544+ else
545+ {
546+ Add-VMImage - sku " 2016-Datacenter-Core" - osDiskLocalPath $ImagePath @PublishArguments - CreateGalleryItem $CreateGalleryItem
547+ }
536548 } catch {
537549 Write-Error - ErrorRecord $_ - ErrorAction Stop
538550 }
@@ -542,8 +554,15 @@ function New-Server2016VMImage {
542554 Write-Verbose - Message " Creating Server Full Image" - Verbose
543555 try {
544556 CreateWindowsVHD @ConvertParams - VHDPath $ImagePath - Edition $FullEdition - ErrorAction Stop - Verbose
545- $description = " This evaluation image should not be used for production workloads."
546- Add-VMImage - sku " 2016-Datacenter" - osDiskLocalPath $ImagePath @PublishArguments - title " Windows Server 2016 Datacenter Eval" - description $description
557+ if ($CreateGalleryItem )
558+ {
559+ $description = " This evaluation image should not be used for production workloads."
560+ Add-VMImage - sku " 2016-Datacenter" - osDiskLocalPath $ImagePath @PublishArguments - title " Windows Server 2016 Datacenter Eval" - description $description - CreateGalleryItem $CreateGalleryItem
561+ }
562+ else
563+ {
564+ Add-VMImage - sku " 2016-Datacenter" - osDiskLocalPath $ImagePath @PublishArguments - CreateGalleryItem $CreateGalleryItem
565+ }
547566 } catch {
548567 Write-Error - ErrorRecord $_ - ErrorAction Stop
549568 }
0 commit comments