Hi,
As per my understanding, you want to write a warning message to SCOM once you the script has restarted the spooler service three times. Please correct me if any misunderstanding. You could simply add counter to your script.
$counter=3
while($counter -gt 0)
{
#your start spooler service code goes here
$counter -= 1
continue
}
Write-WarningMessage "Spooler Stopped"
Best Regards,
Ian
Please remember to "Accept Answer" and upvote if the reply is helpful.