Az.LabServices is a PowerShell module to simplify the management of Azure Lab services. It provides composable functions for IT, educator and student audiences. For IT, there are functions to create, query, update and delete lab accounts, labs, VMs and images. For students, there are newly added functions to help manage their virtual machines.
Getting Started
Install-Module Az
Invoke-WebRequest 'https://raw.githubusercontent.com/Azure/azure-devtestlab/master/samples/ClassroomLabs/Modules/Library/Az.LabServices.psm1' -OutFile 'Az.LabServices.psm1'
Import-Module .\Az.LabServices.psm1 -Force
Login-AzAccount
For IT and educators, make sure your context is set to the subscription you are interested in by using Set-AzContext. Student related functions are subscription agnostic, so don’t worry about the AzContext for those.
Examples for IT and Educators
For IT, there are functions to help manage lab accounts, labs, VMs and Images. Let’s go over a few examples to see what we can do.
Get-AzLabAccount | Get-AzLab
To stop all running lab virtual machine for specific lab:
Get-AzLabAccount | Get-AzLab -LabName ‘my-lab-name’ | Get-AzLabVm -Status Running
To print the email address of the students for a lab:
Get-AzLabAccount | Get-AzLab -LabName ‘my-lab-name’ | Get-AzLabVm | Get-AzLabUser | ForEach-Object {Write-Host $_.properties.email}
More complex examples of usage are in the Az.LabServices scenarios. For an example that creates a lab, see create an ethical hacking class example.
Examples for Students
There are four functions in the Az.LabServices PowerShell module designed just for students. You can start and stop your student virtual machines with Start-AzLabStudentVm and Stop-AzLabStudentVm. Use Get-AzLabStudentVm to get a list of assigned virtual machines. Lastly Get-AzLabStudentCurrentVm will get the information for the lab VM a student is currently logged into. Let’s go over some examples.
Get-AzLabStudentVm | where name -eq ‘my-class-lab-name’ |Start-AzLabStudentVm
Get-AzLabStudentVm -Status Running | Stop-AzLabStudentVm
Get-AzLabStudentCurrentVm | Stop-AzLabStudentVm
We hope you find Az.LabServices PowerShell module helpful. Let us know if you have any feedback or questions for us in the comments section.
-Lab Services team
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.