Checking Success of Command

by Jul 29, 2016

PowerShell 3+

Often, all you want is suppress errors, and find out whether a given cmdlet worked or not.

Here is a very simplistic approach that does just this:

$service = Get-Service -Name AdobeARMservice44 -ErrorAction Ignore
$ok = $?

No error messages are emitted, and $ok is $true if the command succeeded, else $false.

Twitter This Tip! ReTweet this Tip!