Skip to content

Instantly share code, notes, and snippets.

@mo6020
Created September 21, 2013 10:56
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 mo6020/6649487 to your computer and use it in GitHub Desktop.
Save mo6020/6649487 to your computer and use it in GitHub Desktop.
Shuts down controllers when UPS failure detected..
<#
.DESCRIPTION
To be run from UPS monitoring server via Windows NT triggers
.EXAMPLE
.\halt_on_power_fail.ps1
.DATE
08-08-2013
.VERSION
0.1
.AUTHOR
Ed Morgan [ed.morgan@ansgroup.co.uk]
.VERSION CONTROL
0.1 - Initial commit
#>
$user = "root"
$rootpw = "password"
$pw = convertto-securestring $userpw -asplaintext -force
$credentials = new-object -typename system.management.automation.pscredential -argumentlist $user,$pw
$arrFilers = ("filer1", "filer2", "filer3", "filer4")
For Each ($filer in $arrFilers) {
# Debug line for testing
#Write-Output "Connecting to $filer: "
Connect-NaController $filer -credential $credentials -https
Invoke-NAssh -Command "cf disable"
Start-Sleep -s 5
Invoke-NAssh -Command "halt"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment