Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Added from http://bretty.me.uk/save-money-using-citrix-octoblu-automation-for-power-management/
# Author: Dave Brett
function Lab-Startup {
$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 on of VM '$VMName'"
Invoke-XenVM -VM $VM -XenAction Start -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 Startup"
$body = "bretty.local - lab has been started"
$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