This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Added from http://bretty.me.uk/save-money-using-citrix-octoblu-automation-for-power-management/ | |
# Author: Dave Brett | |
function Lab-Shutdown { | |
$ErrorActionPreference = 'Continue' | |
import-module XenServerPSModule | |
connect-xenserver -url http://xs.bretty.local -username USERNAME -password PASSWORD | |
$file = "c:\Scripts\vmlist.txt" | |
$VMNames = Get-Content $file | |
foreach($VMName in $VMNames) | |
{ | |
$VM = Get-XenVM -Name $VMName | |
Write-Host "Scheduling Power off of VM '$VMName'" | |
Invoke-XenVM -VM $VM -XenAction CleanShutdown -Async | |
} | |
Disconnect-XenServer | |
$From = "xs@bretty.me.uk" | |
$To = "dave@bretty.me.uk" | |
$SMTPServer = "xsmail.bretty.me.uk" | |
$SMTPPort = "25" | |
$Username = "xs@bretty.me.uk" | |
$Password = "PASSWORD" | |
$subject = "bretty.local Lab Shutdown" | |
$body = "bretty.local - lab has been shutdown" | |
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort); | |
$smtp.EnableSSL = $false | |
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password); | |
$smtp.Send($From, $To, $subject, $body); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment