Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
$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