Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save srpomeroy/b28894f5a63963b9cb03f4f748671138 to your computer and use it in GitHub Desktop.
Save srpomeroy/b28894f5a63963b9cb03f4f748671138 to your computer and use it in GitHub Desktop.
RightScale/Rightlink10/RSC Call additional script on terminate
$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