Skip to content

Instantly share code, notes, and snippets.

@belotn
Last active December 19, 2015 21:18
Show Gist options
  • Save belotn/6018900 to your computer and use it in GitHub Desktop.
Save belotn/6018900 to your computer and use it in GitHub Desktop.
Move servers to a new zone base on their IPs
get-xaserver |? { $_.IPAddresses -match $MyIp } |? { |select ServerName,@{N="Session";E={@(get-xasession -ServerName $_.ServerName |?{ $_.State -eq "Connected" -and $_.SessionId -gt 0}).Count}} |? { $_.session -eq 0 } |%{ if( $(Get-Xaserver -Servername $_.ServerName).ZoneName -ne $newZone){ set-xaserverzone -ServerNAme $_.Servername -ZoneName $newZone; Restart-Computer $_.ServerName } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment