This commit is contained in:
Drew McDaniel 2017-10-13 00:48:39 -07:00 коммит произвёл GitHub
Родитель 3d8d4c5722
Коммит ebe5232cec
1 изменённых файлов: 39 добавлений и 47 удалений

Просмотреть файл

@ -13,56 +13,48 @@ $subscriptions=Get-AzureRmSubscription
foreach ($sub in $subscriptions){
#
# Make the current subscription active
#
Select-AzureRmSubscription -SubscriptionName $sub.Name
Set-AzureRmContext -Subscription $sub.Name
$ctx = Get-AzureRmContext
Start-Job {param ($ctx,$sub,$location,$sourceURI,$storageId,$RGName,$snapName,$imageNameRegional)
#
# Create a snapshot from the remote blob
#
write-host "Creating Snapshot"
$snapshotConfig = New-AzureRmSnapshotConfig -AccountType StandardLRS `
-OsType Windows `
-Location $location `
-CreateOption Import `
-SourceUri $sourceURI `
-StorageAccountId $storageId
#
# Create a snapshot from the remote blob
#
write-host "Creating Snapshot"
$snapshotConfig = New-AzureRmSnapshotConfig -AccountType StandardLRS `
-OsType Windows `
-Location $location `
-CreateOption Import `
-SourceUri $sourceURI `
-StorageAccountId $storageId
$snap = New-AzureRmSnapshot -AzureRmContext $ctx `
-ResourceGroupName $RGName `
-SnapshotName $snapName `
-Snapshot $snapshotConfig
#
# Create an image from the snapshot
#
write-host "Creating Image from Snapshot"
$imageConfig = New-AzureRmImageConfig -Location $location
$snap = New-AzureRmSnapshot -ResourceGroupName $RGName `
-SnapshotName $snapName `
-Snapshot $snapshotConfig
#
# Create an image from the snapshot
#
write-host "Creating Image from Snapshot"
$imageConfig = New-AzureRmImageConfig -Location $location
Set-AzureRmImageOsDisk -Image $imageConfig `
-OsType Windows `
-OsState Generalized `
-SnapshotId $snap.Id
Set-AzureRmImageOsDisk -Image $imageConfig `
-OsType Windows `
-OsState Generalized `
-SnapshotId $snap.Id
New-AzureRmImage -ResourceGroupName $RGName `
-ImageName $imageNameRegional `
-Image $imageConfig
New-AzureRmImage -AzureRmContext $ctx `
-ResourceGroupName $RGName `
-ImageName $imageNameRegional `
-Image $imageConfig
#
# Cleanup snapshot
#
write-host "Deleting Snapshot"
Remove-AzureRmSnapshot -AzureRmContext $ctx -ResourceGroupName $RGName -SnapshotName $snapName -force
}
foreach ($sub in $subscriptions){
#
# Make the current subscription active
#
Select-AzureRmSubscription -SubscriptionName $sub.Name
#
# Cleanup snapshot
#
write-host "Deleting Snapshot"
Remove-AzureRmSnapshot -ResourceGroupName $RGName -SnapshotName $snapName -force
} -ArgumentList $ctx,$sub,$location,$sourceURI,$storageId,$RGName,$snapName,$imageNameRegional
}