Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alainassaf
Last active July 27, 2018 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alainassaf/c72b88ba606331ce2ca72db96a7bcc4e to your computer and use it in GitHub Desktop.
Save alainassaf/c72b88ba606331ce2ca72db96a7bcc4e to your computer and use it in GitHub Desktop.
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