This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.
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
- Make sure you have a recent Azure PowerShell Module installed.
Install-Module Az - Copy Az.LabServices.psm1 anywhere on disk
Invoke-WebRequest 'https://raw.githubusercontent.com/Azure/azure-devtestlab/master/samples/ClassroomLabs/Modules/Library/Az.LabServices.psm1' -OutFile 'Az.LabServices.psm1' - Import the Az.LabServices module.
Import-Module .\Az.LabServices.psm1 -Force - Sign-in.
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.
- To see all the labs in a subscription:
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.
- To start a lab virtual machine for a specific class:
Get-AzLabStudentVm | where name -eq ‘my-class-lab-name’ |Start-AzLabStudentVm - To stop all of your running lab virtual machines:
Get-AzLabStudentVm -Status Running | Stop-AzLabStudentVm - Want to stop the machine you’re currently logged onto and stop using quota?
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