title: Checking if Distribution Group Exists in Powershell
body: <p>I am writing a script to quickly create a new distribution group and populate it with a CSV. I am having trouble testing to see if the group name already exists.</p>
  
  <p>If I do a <code>get-distributiongroup -id $NewGroupName</code> and it does not exist I get an exception, which is what I expect to happen. If the group does exist then it lists the group, which is also what I expect. However, I can not find a good way to test if the group exists before I try to create it. I have tried using a try/catch, and also doing this:</p>
  
  <pre><code>Get-DistributionGroup -id $NewGroupName -ErrorAction "Stop" 
  </code></pre>
  
  <p>which makes the try/catch work better (as I understand non-terminating errors).</p>
  
  <p>Basically, I need to have the user enter a new group name to check if it is viable. If so, then the group gets created, if not it should prompt the user to enter another name. </p>