Created
November 4, 2016 14:43
-
-
Save torgro/fb73b5993791c3d275088ecfa676aa76 to your computer and use it in GitHub Desktop.
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-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