Design a site like this with WordPress.com
Get started

Three Ways to Make a Powershell Query


Below are three ways in which you can make a powershell query

  1. Get-QADuser – Uses Quest cmdlet technology
  2. ADSI namespace – Uses System.DirectoryServices
  3. Find-LdapObject – Uses System.DirectoryServices.Protocols

Among the three ways, the third way is the fastest method.

Method of Query:

1. Using the Quest Active Directory CmdLet Get-QADuser:

$MigratedUsers=get-qaduser -ldapfilter “(attribute=value)”

2. Using the ADSI interface with the “System.DirectoryServices.DirectorySearcher” object:

$root = [ADSI]”LDAP://” $search = new-Object System.DirectoryServices.DirectorySearcher($root,”(attribute=value)”)

$MigratedUsers = $search.FindAll()

3. Find-LdapObject:

“System.DirectoryServices.Protocols“. Here is the link to the Microsoft website were you can download and save the modules locally and load it into powershell.

To load into powershell:

Add-Type -AssemblyName System.DirectoryServices.Protocols

Import-modules “C:\S.DS.P.psm1”

To use the cmdlet:

$MigratedUsers=Find-LdapObject -SearchFilter:”(attribute=value)” -SearchBase:”DC=Domain,DC=com” -LdapServer: “” -PageSize 500