O R G A N I C / F E R T I L I Z E R: misc: dsquery vs powershell (2)

Feb 8, 2008

misc: dsquery vs powershell (2)

this time, i'm going to show you how to retrieve the group membership of a user.  so to begin with, in cmd shell with dsquery:

dsquery user -samid username | dsget user -memberof

and in powershell:

(Get-QADUser -samaccountname username).memberof

look at that, the powershell command-line is in fact, just a tiny bit shorter.  if you run them both, though, dsquery does outperform powershell by a large margin in this demonstration.  still, you have to learn this stuff sooner or later.  :)

now, if you run it as two separate commands, powershell performs just as fast as dsquery (to the human eye at least).  like this:

$user = get-qaduser -samaccountname username