Skip to content

Instantly share code, notes, and snippets.

Last active July 27, 2018 14:09
What would you like to do?
Getting, counting, saving
# Retrieve the information
$XenServerVMs = Get-XenVM | Where-Object {$_.is_a_snapshot -eq $false -and $_.is_a_template -eq $false -and $_.is_control_domain -eq $false -and $_.power_state -eq 'running'} | Select-Object name_label
$vmCount = $XenServerVMs.count
$objctxsrv = new-object System.Object
$objctxsrv | Add-Member -type NoteProperty -name XenServer -value $xsn
$objctxsrv | Add-Member -type NoteProperty -name 'VM Count' -value ($vmCount)
$finalout += $objctxsrv
# Disconnect from the XenServer pool
Get-XenSession -Server $_ | Disconnect-XenServer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment