public/New-SilkTCOVMList.ps1
|
function New-SilkTCOVMList { param( [Parameter()] [string] $subscriptionName, [Parameter()] [string] $inputFile, [Parameter()] [array] $resourceGroupNames, [Parameter()] [array] $zones, [Parameter()] [switch] $allVMs ) if ($inputFile) { $vmlist = Get-Content $inputFile | ForEach-Object { Get-AzVM -Name $_ -Status } } else { $vmlist = Get-AzVM -Status } if ($resourceGroupNames) { $vmlist = foreach ($r in $resourceGroupNames) { $vmlist | Where-Object { $_.ResourceGroupName -contains $r } } } if ($zones) { $vmlist = foreach ($z in $zones) { $vmlist | Where-Object { $_.Zones -contains $z } } } if (!$allVMs) { $vmlist = $vmlist | Where-Object { $_.PowerState -eq 'VM running' } } return $vmlist } |