Created
September 16, 2021 18:38
-
-
Save barretts/1ede30fd8243d5edf60f4b64aeb40fe4 to your computer and use it in GitHub Desktop.
trigger webhook when command is finished
This file contains hidden or 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
function CallWhenDoneFunc { | |
$mergedCmd = $args -join " " | |
Invoke-Expression $mergedCmd | |
# use content in payload for discord instead of text | |
$hookUrl = "https://hooks.slack.com/services/yoururlgoeshere" | |
$content = "Finished $mergedCmd" | |
$payload = [PSCustomObject]@{ | |
text = $content | |
} | |
Invoke-RestMethod -Uri $hookUrl -Method Post -Body ($payload | ConvertTo-Json) -ContentType 'Application/Json' | |
} | |
Set-Alias CallWhenDone CallWhenDoneFunc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment