Convert to run parallel
This commit is contained in:
Родитель
3d8d4c5722
Коммит
ebe5232cec
|
@ -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
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче