PowerShell Scripts, Tips, Expert Advices, Forums, and Resources

Geek Sync Live

Welcome to PowerShell.com, the educational and community site for Windows PowerShell People. Get a quick overview.

Latest Blog Posts

07-29-2016 - SysAdmin Day
07-29-2016 - Checking Success of Command
07-28-2016 - .psd1 files

As a Powershell.com member you will have access to:

  • Daily PowerShell tips written by Microsoft MVPs and other leading Windows PowerShell experts
  • Free Windows PowerShell advice and training provided by Microsoft MVPs and other leading Windows PowerShell experts
  • Access to leading Windows PowerShell blogs
  • A free ebook, Mastering PowerShell, written by Microsoft MVP Dr. Tobias Weltner
PowerTip of the Day

Checking Success of Command

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!

Copyright 2012 PowerShell.com. All rights reserved.