forked from lucabol/DTLCustomImagesLab
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Get-VmStatus.ps1
28 lines (23 loc) · 985 Bytes
/
Get-VmStatus.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
param
(
[Parameter(Mandatory=$false, HelpMessage="Configuration File, see example in directory")]
[ValidateNotNullOrEmpty()]
[string] $ConfigFile = "config.csv"
)
$ErrorActionPreference = "Stop"
. "./Utils.ps1"
Import-AzDtlModule
# Read in the config file
$config = Import-Csv $ConfigFile
# Foreach lab, get all the VMs
$config | ForEach-Object {
Write-Host "----------------------------------------------" -ForegroundColor Green
Write-Host "DevTestLab: $($_.DevTestLabName)" -ForegroundColor Green
$vms = Get-AzDtlVm -Lab @{Name = $_.DevTestLabName; ResourceGroupName = $_.ResourceGroupName}
$vms | Select-Object `
@{label="Name";expression={$_.Name}},
@{label="ProvisioningState";expression={$_.Properties.provisioningState}},
@{label="PowerState";expression={$_.Properties.lastKnownPowerState}},
@{label="ArtifactStatus";expression={$_.Properties.ArtifactDeploymentStatus.deploymentStatus}} `
| Format-Table
}