Author Posts

January 1, 2012 at 12:00 am

by i255d at 2013-03-05 08:45:31

I have all 2003 Domain controllers in my enviornment for now. Untill we can upgrade, I need to be able to user PowerShell to access list of computers by UI or Groups and Users by UI or groups. I found an old article that says it can be done, but I can't get it to work for me. I can't put Powershell on these servers.

Here is what I have so far.

$strFilter = "(&(objectCategory=User)(Department='Operations'))"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher

$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"

$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{$objItem = $objResult.Properties; $objItem.name}

When I use this, I get results 0

Can someone work with me to learn how to put this to use in my enviornment?

by DexterPOSH at 2013-03-05 09:16:35

Hi ,

The above approach should work fine for your Environment as you are tapping into .NET framework directly.
But this becomes cryptic to understand and follow...a better way in my opinion (solely ) is to use Quest AD cmdlets as a beginner. I do the same.
Those are free and easy to use and should work with your environment as well.

What you are trying to achive above can be done as below using Quest AD Cmdlets
Get-QADUser -Department Operations
I will check your code and get back as to why it doesn't work.

~regards~
Dexter

by i255d at 2013-03-05 09:30:40

Do I just put the Quest AD Cmdlets on my desktop and they can access the DC's?
Also, I have PowerShell v.3 on my desktop, will they work with this?

by DexterPOSH at 2013-03-07 02:24:45

Yes...just install it and add the snapins to your session.
I found the below link which describes it.

http://desktopfeedbag.com/2008/08/02/how-to-add-quest-ad-tools-to-your-native-powershell/
I think it should work fine with PowerShell v3 as well. If not let us know

Hope it helps