title: Hiding Errors When Using Get-ADGroup
body: <p>I'm working on a script that will build a new group if it doesn't exist.  I'm using Get-ADGroup to make sure the group doesn't exist using the following command:</p>
  
  <pre><code>$group = get-adgroup $groupName -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue 
  </code></pre>
  
  <p>But when I do I get the following error (I removed any domain specific data from the error):</p>
  
  <pre><code>Get-ADGroup : Cannot find an object with identity: '*group name*' under: '*domain*'.
  At U:\Scripts\Windows\Create-FolderAccessGroup.ps1:23 char:24
  + $group = get-adgroup &lt;&lt;&lt;&lt; $groupName -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue
      + CategoryInfo          : ObjectNotFound: (y:ADGroup) [Get-ADGroup], ADIdentityNot
     FoundException
      + FullyQualifiedErrorId : Cannot find an object with identity: '' under: ''.,Microsoft.ActiveDirectory.Management.Commands.GetADGroup
  </code></pre>
  
  <p>I assumed setting ErrorAction and WarningAction to SilentlyContinue would keep this error from being displayed but it hasn't.</p>