Skip to content

Commit ffa985a

Browse files
Merge pull request #219902 from ntrogh/als-ps-sku
[Azure Lab Services] Added PS command to retrieve the list of SKUs
2 parents cfb068d + 86c1a57 commit ffa985a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

articles/lab-services/quick-create-lab-powershell.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ We'll choose the Windows 11 image.
5353
$image = $plan | Get-AzLabServicesPlanImage | Where-Object { $_.EnabledState.ToString() -eq "enabled" -and $_.DisplayName -eq "Windows 11 Pro (Gen2)" }
5454
```
5555

56-
We're now ready to create a lab based of our lab plan with the Window 11 Pro image. The following command will create a lab using the lab plan created above.
56+
When you create a lab by using PowerShell, you also need to provide the resource SKU information. The following command uses the [REST API to retrieve the list of SKUs](/rest/api/labservices/skus/list) and selects the `Classic_Fsv2_4_8GB_128_S_SSD` SKU:
57+
58+
```powershell
59+
$subscriptionId = (Get-AzContext).Subscription.ID
60+
$skus = (Invoke-AzRestMethod -Uri https://management.azure.com/subscriptions/$subscriptionId/providers/Microsoft.LabServices/skus?api-version=2022-08-01 | Select-Object -Property "Content" -ExpandProperty Content | ConvertFrom-Json).value
61+
$sku = $skus | Where-Object -Property "name" -eq "Classic_Fsv2_4_8GB_128_S_SSD" | select-object -First 1
62+
```
63+
64+
We're now ready to create a lab based of our lab plan with the Window 11 Pro image and the `Classic_Fsv2_4_8GB_128_S_SSD` resource SKU. The following command will create a lab using the lab plan created above.
5765

5866
``` powershell
5967
# $plan and $image are from the Create LabPlan QuickStart.
@@ -84,7 +92,7 @@ $lab = New-AzLabServicesLab -Name "ContosoLab" `
8492
-ImageReferenceSku $image.Sku `
8593
-ImageReferenceVersion $image.Version `
8694
-SkuCapacity 1 `
87-
-SkuName "Classic_Fsv2_4_8GB_128_S_SSD" `
95+
-SkuName $sku.size `
8896
`
8997
-Title "Contoso Lab" `
9098
-Description "The Contoso lab" `

0 commit comments

Comments
 (0)