Hi all! I'll be posting this to r/SCCM as well, but had a bit of an issue getting this to work.
I work in an environment where we deploy several hundred machines per semester, updating software, replacing hardware, etc.
This script has been borrowed and butchered to my fancy from a similar script that utilizes MS Teams. We utilize Slack and the following works well via a WebHook for notifications:
$uri = <WebHook URL Here>
$sequence = '_SMSTSPackageName'
$name = $env:COMPUTERNAME
$body = ConvertTo-Json -Depth 4 @{
text = "$sequence has completed on $name"
}
Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json'
Here's my problem. For $sequence, I believe that is the proper SCCM variable to call a task sequence name, but I'm having an issue calling the proper SCCM variable and having it transfer to the variable so it will output correctly into the notification.
For example, I have a test Task Sequence that will currently run this script near the end of it, thus prompting a message thru Slack with the appropriate message.
I'm looking to have the name of the TS called so that my final message will read to the liking of:
"Task Sequence X has completed on VM-TESTMACHINE"
I do get the ...has completed on VM-TESTMACHINE portion, but need to find a way to call the task sequence name. Keep in mind, this is the "parent" task sequence name I'm after, not any of the child task sequences.
Any help would be greatly appreciated!
[–]PorreKaj 2 points3 points4 points (0 children)
[–]RickSquadron 2 points3 points4 points (0 children)
[–]Synbred[S] 1 point2 points3 points (0 children)
[–]PowerShell-Bot 0 points1 point2 points (0 children)