Skip to content

Instantly share code, notes, and snippets.

@torgro
Created November 4, 2016 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torgro/33a659b5e41508ed127e16cd3c5798a9 to your computer and use it in GitHub Desktop.
Save torgro/33a659b5e41508ed127e16cd3c5798a9 to your computer and use it in GitHub Desktop.
$vmListFilePath = "c:\Scripts\vmlist.txt"
. c:\scripts\Set-LabPowerState.ps1
if (Test-Path -Path "$vmListFilePath")
{
$setLabPower = @{
Credential = Import-Clixml -Path "c:\scripts\XenCred.xml"
XenServerUrl = "http://xs.bretty.local"
Shutdown = $true
}
$result = foreach($vm in (Get-Content -Path "$vmListFilePath"))
{
Set-LabPowerState @setLabPower -VMname $vm
}
$sendMail = @{
From = "xs@bretty.me.uk"
To = "dave@bretty.me.uk"
SMTPServer = "xsmail.bretty.me.uk"
Subject = "bretty.local Lab action"
Body = $result | Out-String
Credential = Import-Clixml -Path "c:\scripts\mailCred.xml"
}
Send-MailMessage @sendMail
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment