Skip to content

Commit af78250

Browse files
committed
final script
1 parent 1b2b540 commit af78250

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

articles/devtest-labs/samples-powershell.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -365,27 +365,28 @@ Set-PolicyChanges $lab $policyChanges
365365

366366
## Create a custom image from a VHD file
367367

368-
This sample PowerShell script creates a custom image from a Windows VHD file in DevTest Labs. To use the script, replace the parameter values under the `# Values to change` comment with your own values. You can get the `subscriptionId`, `labRg`, and `labName` values from the lab's main page in the Azure portal.
368+
This sample PowerShell script creates a custom image in DevTest Labs from a Windows VHD file. The script requires a VHD file to be uploaded to the Azure Storage account for the lab.
369369

370+
To use the script, replace the parameter values under the `# Values to change` comment with your own values. You can get the `subscriptionId`, `labRg`, and `labName` values from the lab's main page in the Azure portal. Get the `vhdUri` value from the Azure Storage container where you uploaded the VHD file.
370371

371372
This script uses the following commands:
372373

373374
| Command | Notes |
374375
|---|---|
375-
| [Get-AzResource](/powershell/module/az.resources/get-azresource) | Gets resources. |
376-
| [Get-AzStorageAccountKey](/powershell/module/az.storage/get-azstorageaccountkey) | Gets the access keys for an Azure Storage account. |
377-
| [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment) | Adds an Azure deployment to a resource group. |
376+
| [Get-AzResource](/powershell/module/az.resources/get-azresource) | Gets resources such as the lab object and lab storage account. |
377+
| [Get-AzStorageAccountKey](/powershell/module/az.storage/get-azstorageaccountkey) | Gets the access keys for the lab storage account. |
378+
| [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment) | Creates the custom image and resource group deployment based on a template. |
378379

379380
```powershell
380381
# Values to change
381-
$subscriptionId = '<Specify your subscription ID here>'
382-
$labRg = '<Specify your lab resource group name here>'
383-
$labName = '<Specify your lab name here>'
384-
$vhdUri = '<Specify the VHD URI here>'
385-
$customImageName = '<Specify the custom image name>'
386-
$customImageDescription = '<Specify the custom image description>'
387-
388-
# Select the desired Azure subscription.
382+
$subscriptionId = '<Azure subscription ID>'
383+
$labRg = '<Lab resource group name>'
384+
$labName = '<Lab name>'
385+
$vhdUri = '<VHD URI>'
386+
$customImageName = '<Name for the custom image>'
387+
$customImageDescription = '<Description for the custom image'
388+
389+
# Select the Azure subscription.
389390
Select-AzSubscription -SubscriptionId $subscriptionId
390391
391392
# Get the lab object.
@@ -398,8 +399,8 @@ $labStorageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $labStorageA
398399
# Set up the parameters object.
399400
$parameters = @{existingLabName="$($lab.Name)"; existingVhdUri=$vhdUri; imageOsType='windows'; isVhdSysPrepped=$false; imageName=$customImageName; imageDescription=$customImageDescription}
400401
401-
# Create the custom image.
402-
New-AzResourceGroupDeployment -ResourceGroupName $lab.ResourceGroupName -Name CreateCustomImage -TemplateUri 'https://raw.githubusercontent.com/Azure/azure-devtestlab/master/Samples/201-dtl-create-customimage-from-vhd/azuredeploy.json' -TemplateParameterObject $parameters
402+
# Create the custom image.
403+
New-AzResourceGroupDeployment -ResourceGroupName $lab.ResourceGroupName -Name CreateCustomImage -TemplateUri 'https://raw.githubusercontent.com/Azure/azure-devtestlab/master/samples/DevTestLabs/QuickStartTemplates/201-dtl-create-customimage-from-vhd/azuredeploy.json' -TemplateParameterObject $parameters
403404
```
404405

405406
## Related content

0 commit comments

Comments
 (0)