title | description | ms.topic | ms.author | author | ms.date |
---|---|---|---|---|---|
Azure PowerShell Samples |
Learn about Azure PowerShell scripts. These samples help you manage labs in Azure Lab Services. |
sample |
rosemalcolm |
RoseHJM |
02/02/2022 |
This article includes the sample Azure PowerShell scripts for Azure Lab Services.
[!INCLUDE updated-for-az]
[!INCLUDE sample-powershell-install]
This article includes the following samples:
Script | Description |
---|---|
Add an external user to a lab | This PowerShell script adds an external user to a lab in Azure DevTest Labs. |
Add marketplace images to a lab | This PowerShell script adds marketplace images to a lab in Azure DevTest Labs. |
Create a custom image from a virtual hard drive (VHD) | This PowerShell script creates a custom image in a lab in Azure DevTest Labs. |
Create a custom role in a lab | This PowerShell script creates a custom role in a lab in Azure Lab Services. |
Set allowed virtual machine sizes in a lab | This PowerShell script sets allowed virtual machine sizes in a lab. |
All of these scripts have the following prerequisite:
- An existing lab. If you don't have one, follow this quickstart on how to Create a lab in Azure portal.
This sample PowerShell script adds an external user to a lab in Azure DevTest Labs.
:::code language="powershell" source="../../powershell_scripts/devtest-lab/add-external-user-to-lab/add-external-user-to-custom-lab.ps1":::
This script uses the following commands:
Command | Notes |
---|---|
Get-AzADUser | Retries the user object from Azure active directory. |
New-AzRoleAssignment | Assigns the specified role to the specified principal, at the specified scope. |
This sample PowerShell script adds a marketplace image to a lab in Azure DevTest Labs.
:::code language="powershell" source="../../powershell_scripts/devtest-lab/add-marketplace-images-to-lab/add-marketplace-images-to-lab.ps1":::
This script uses the following commands:
Command | Notes |
---|---|
Get-AzResource | Gets resources. |
Set-AzResource | Modifies a resource. |
New-AzResource | Create a resource. |
This sample PowerShell script creates a custom image from a VHD file in Azure Lab Services.
:::code language="powershell" source="../../powershell_scripts/devtest-lab/create-custom-image-from-vhd/create-custom-image-from-vhd.ps1":::
This script uses the following commands:
Command | Notes |
---|---|
Get-AzResource | Gets resources. |
Get-AzStorageAccountKey | Gets the access keys for an Azure Storage account. |
New-AzResourceGroupDeployment | Adds an Azure deployment to a resource group. |
This sample PowerShell script creates a custom role to use in a lab in Azure DevTest Labs.
:::code language="powershell" source="../../powershell_scripts/devtest-lab/create-custom-role-in-lab/create-custom-role-in-lab.ps1":::
This script uses the following commands:
Command | Notes |
---|---|
Get-AzProviderOperation | Gets the operations for an Azure resource provider that are securable using Azure role-based access control. |
Get-AzRoleDefinition | Lists all Azure roles that are available for assignment. |
New-AzRoleDefinition | Creates a custom role. |
This sample PowerShell script sets allowed virtual machine sizes in Azure Lab Services.
:::code language="powershell" source="../../powershell_scripts/devtest-lab/set-allowed-vm-sizes-in-lab/set-allowed-vm-sizes-in-lab.ps1":::
Command | Notes |
---|---|
Get-AzResource | Gets resources. |
Set-AzResource | Modifies a resource. |
New-AzResource | Create a resource. |
For more information on Azure PowerShell, see Azure PowerShell documentation.