Created
February 24, 2017 04:18
-
-
Save srpomeroy/b28894f5a63963b9cb03f4f748671138 to your computer and use it in GitHub Desktop.
RightScale/Rightlink10/RSC Call additional script on terminate
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
$erroractionpreference = "Stop" | |
$rightlink_dir = 'C:\Program Files\RightScale\RightLink' | |
$decom_reason = & "${rightlink_dir}\rsc.exe" rl10 show /rll/proc/shutdown_kind | |
$rightScriptID = "123456789" | |
If ($decom_reason -eq "terminate") { | |
Write-Output "Instance is terminating. Running script..." | |
#Run RightScript | |
& "${rightlink_dir}\rsc.exe" rl10 run_right_script /rll/run/right_script "right_script_id=$rightScriptID" | |
#Give the process some time to complete... | |
Start-Sleep -Seconds 180 | |
} | |
else { | |
Write-Output "Instance is NOT terminating. Skipping..." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment