title: Check if AD group exists or not
body: <p>Trying to check if AD group exists or not using below script :</p>
  
  <pre><code>$Path = "LDAP://dc=cmc,dc=com"
  $object = "CMC\QTKS-DEP-Admin-Temp"
  $type = "Group"
  
  $search = [System.DirectoryServices.DirectorySearcher]$Path
  $search.Filter = "(&amp;(name=$object)(objectCategory=$type))"
  $Result = $search.FindOne()
  
  IF( $Result -eq $null)
  {
  Write-Host "Group does not exist"
  }
  Else 
  {   
  Write-Host "Group exists"
  }
  </code></pre>
  
  <p>I know something wrong with the LDAP connection string or variables declarations. Or something else. Can someone please correct. The result always shows as "Group does not exist" even if it exists.</p>