Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- asnp Citrix*
- $Bad = ""
- $date = Get-Date
- $numofmins = 20
- $VMName = Get-VM -Name *p*t* -ComputerName (Get-ClusterNode -Cluster CLUSTER) | select -ExpandProperty Name
- foreach ($VM in $VMName) {
- $CitrixVM = Get-BrokerDesktop -AdminAddress 10.1.1.11 -MachineName "LHI\$VM"
- $MailMessage = @{
- To = "support@nextstepta.com"
- From = "robot@lh-inc.com"
- Body = "Please make sure the VMs are restarted. The script should have restarted the virtul machine(s)."
- Smtpserver = "10.1.1.51"
- ErrorAction = "SilentlyContinue"
- }
- if ($CitrixVM.RegistrationState = "Unregistered") {
- if($CitrixVM.LastDeregistrationTime -le $Date.AddMinutes(-$numofmins)) {
- $Bad = $CitrixVM.MachineName
- Send-MailMessage @MailMessage -Port 25 -Subject "Citrix VM down.. $bad"
- Stop-VM -Name $VM -Force
- Start-Sleep -Seconds 10
- Start-VM -Name $VM
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement