Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Quest AD help

Reply
 
Old 09-11-2007   #1 (permalink)
Ian_1


 
 

Quest AD help

Looking for the Quest PS code to query a group in AD
(LDAP://cn=accountants,ou=city,ou=com) and pull first name, last name,
display, and email address. Im looking while this is posted, just any help
while Im under a deadline would be greatly appreciated. Thank!

My System SpecsSystem Spec
Old 09-11-2007   #2 (permalink)
Bob Landau


 
 

RE: Quest AD help

I never heard of the Quest Directory Service but since it speaks LDAP the
following should get you in the right directory. In your case you'll need to
change the ADSI moniker to your name space as well as the filter


## Access the AD using the underlying DirectoryServices .Net class
## this allows you to do everything about including to enumerate
## the container you're in much like DIR does.
##
##
http://msdn2.microsoft.com/en-us/lib...rs(vs.71).aspx
##
$root = 'LDAP://OU=Enterprise, OU=NextGen DC=Continuum, DC=local'
$searcher = new-object System.DirectoryServices.DirectorySearcher($root)
$searcher.filter = "(&(objectClass=user)(cn=*Picard)"
$searcher.findall() | % {$_.path}



"Ian_1" wrote:
Quote:

> Looking for the Quest PS code to query a group in AD
> (LDAP://cn=accountants,ou=city,ou=com) and pull first name, last name,
> display, and email address. Im looking while this is posted, just any help
> while Im under a deadline would be greatly appreciated. Thank!
My System SpecsSystem Spec
Old 09-11-2007   #3 (permalink)
Ian_1


 
 

RE: Quest AD help

Sorry, your script doen't not work. I should not have been specific to just
Quest. It can be WMI, or .NET, or utilizing the ADSI accelerator, etc, it
really doesn't matter. Since this is the point of scripting to make life
simple, surely it's as easy as ? (still researching)
My System SpecsSystem Spec
Old 09-11-2007   #4 (permalink)
Brandon Shell


 
 

Re: Quest AD help

How bout this.

$group = [ADSI]"LDAP://cn=accountants,ou=city,ou=com"
foreach($member in $group.member)
{
$user = [ADSI]"LDAP://$member"
Write-Host ("First Name:{0}" -f ($user.givenName).ToString())
Write-Host ("Last Name:{0}" -f ($user.sn).ToString())
Write-Host ("Display Name:{0}" -f ($user.Displayname).ToString())
Write-Host ("Email:{0}" -f ($user.mail).ToString())
Write-Host
}

"Ian_1" <fakeaddy@xxxxxx> wrote in message
news:B7B657F9-9788-4E5D-8E9B-6448345BAB70@xxxxxx
Quote:

> Sorry, your script doen't not work. I should not have been specific to
> just
> Quest. It can be WMI, or .NET, or utilizing the ADSI accelerator, etc, it
> really doesn't matter. Since this is the point of scripting to make life
> simple, surely it's as easy as ? (still researching)
My System SpecsSystem Spec
Old 09-11-2007   #5 (permalink)
Bob Landau


 
 

RE: Quest AD help

You are quite correct on both accounts

It is not hard; but I won't say that it's easy unless you are at least some
what acquainted with the .NET Directory Services classes.

The code I posted did not work I'm not sure why it didn't return an error
but thats an adventure for another day.

When I cut and pasted my code into the reply I missed the [ADSI] type so the
constructor never got constructed or should I say the [ADSI] ctor didn't.
What you got back was a STRING.

Add one very small change

$root = [ADSI] 'LDAP://OU=Enterprise, OU=NextGen DC=Continuum, DC=local'
$searcher = new-object System.DirectoryServices.DirectorySearcher($root)
$searcher.filter = "(&(objectClass=user)(cn=*Picard)"
$searcher.findall() | % {$_.path}

Again you must changes the moniker to reflect your DS namespace.

Here is one other URL which I found using MSN Live it's at the top of the
list and was one of the pages I used to learn about ADSI

http://www.microsoft.com/technet/tec...l/default.aspx

thx
bob

"Ian_1" wrote:
Quote:

> Sorry, your script doen't not work. I should not have been specific to just
> Quest. It can be WMI, or .NET, or utilizing the ADSI accelerator, etc, it
> really doesn't matter. Since this is the point of scripting to make life
> simple, surely it's as easy as ? (still researching)
My System SpecsSystem Spec
Old 09-11-2007   #6 (permalink)
Brandon Shell


 
 

Re: Quest AD help

It should at least error... It work perfectly for me.
What is $error?

"Ian_1" <fakeaddy@xxxxxx> wrote in message
news:8B76F27C-21F9-4FC6-9126-4429128C6C90@xxxxxx
Quote:

> Strangely, I copy and paste that, save as a PS1 and run it - it does
> nothing.
> I've chaged OU's and CN's - nothing. It just acts like I've pressed enter.
> Weird.
>
> "Brandon Shell" wrote:
>
Quote:

>> How bout this.
>>
>> $group = [ADSI]"LDAP://cn=accountants,ou=city,ou=com"
>> foreach($member in $group.member)
>> {
>> $user = [ADSI]"LDAP://$member"
>> Write-Host ("First Name:{0}" -f ($user.givenName).ToString())
>> Write-Host ("Last Name:{0}" -f ($user.sn).ToString())
>> Write-Host ("Display Name:{0}" -f ($user.Displayname).ToString())
>> Write-Host ("Email:{0}" -f ($user.mail).ToString())
>> Write-Host
>> }
>>
>> "Ian_1" <fakeaddy@xxxxxx> wrote in message
>> news:B7B657F9-9788-4E5D-8E9B-6448345BAB70@xxxxxx
Quote:

>> > Sorry, your script doen't not work. I should not have been specific to
>> > just
>> > Quest. It can be WMI, or .NET, or utilizing the ADSI accelerator, etc,
>> > it
>> > really doesn't matter. Since this is the point of scripting to make
>> > life
>> > simple, surely it's as easy as ? (still researching)
>>
>>
My System SpecsSystem Spec
Old 09-11-2007   #7 (permalink)
Ian_1


 
 

Re: Quest AD help

Strangely, I copy and paste that, save as a PS1 and run it - it does nothing.
I've chaged OU's and CN's - nothing. It just acts like I've pressed enter.
Weird.

"Brandon Shell" wrote:
Quote:

> How bout this.
>
> $group = [ADSI]"LDAP://cn=accountants,ou=city,ou=com"
> foreach($member in $group.member)
> {
> $user = [ADSI]"LDAP://$member"
> Write-Host ("First Name:{0}" -f ($user.givenName).ToString())
> Write-Host ("Last Name:{0}" -f ($user.sn).ToString())
> Write-Host ("Display Name:{0}" -f ($user.Displayname).ToString())
> Write-Host ("Email:{0}" -f ($user.mail).ToString())
> Write-Host
> }
>
> "Ian_1" <fakeaddy@xxxxxx> wrote in message
> news:B7B657F9-9788-4E5D-8E9B-6448345BAB70@xxxxxx
Quote:

> > Sorry, your script doen't not work. I should not have been specific to
> > just
> > Quest. It can be WMI, or .NET, or utilizing the ADSI accelerator, etc, it
> > really doesn't matter. Since this is the point of scripting to make life
> > simple, surely it's as easy as ? (still researching)
>
>
My System SpecsSystem Spec
Old 09-11-2007   #8 (permalink)
Ian_1


 
 

RE: Quest AD help

What is with "(cn=*Picard)" -- Im not looking for any certian user, but I
tried it both with it and without it for us. I need a list of users in a .CSV
format - firstname, lastname, middle initial, email address.. Thanks

Here's the error I got Bob:
An error occurred while enumerating through a collection: The
(&(objectClass=user)(cn=*picard) search filter is invalid
...
At C:\scripts\Ad_Connection2.ps1:4 char:1
+ $ <<<< searcher.findall() | % {$_.path}




"Bob Landau" wrote:
Quote:

> You are quite correct on both accounts
>
> It is not hard; but I won't say that it's easy unless you are at least some
> what acquainted with the .NET Directory Services classes.
>
> The code I posted did not work I'm not sure why it didn't return an error
> but thats an adventure for another day.
>
> When I cut and pasted my code into the reply I missed the [ADSI] type so the
> constructor never got constructed or should I say the [ADSI] ctor didn't.
> What you got back was a STRING.
>
> Add one very small change
>
> $root = [ADSI] 'LDAP://OU=Enterprise, OU=NextGen DC=Continuum, DC=local'
> $searcher = new-object System.DirectoryServices.DirectorySearcher($root)
> $searcher.filter = "(&(objectClass=user)(cn=*Picard)"
> $searcher.findall() | % {$_.path}
>
> Again you must changes the moniker to reflect your DS namespace.
>
> Here is one other URL which I found using MSN Live it's at the top of the
> list and was one of the pages I used to learn about ADSI
>
> http://www.microsoft.com/technet/tec...l/default.aspx
>
> thx
> bob
>
> "Ian_1" wrote:
>
Quote:

> > Sorry, your script doen't not work. I should not have been specific to just
> > Quest. It can be WMI, or .NET, or utilizing the ADSI accelerator, etc, it
> > really doesn't matter. Since this is the point of scripting to make life
> > simple, surely it's as easy as ? (still researching)
My System SpecsSystem Spec
Old 09-11-2007   #9 (permalink)
Ian_1


 
 

Re: Quest AD help

Like I wrote Brandon, it does nothing, just goes from one line to the next:

PS C:\scripts> C:\scripts\All_Test.ps1
PS C:\scripts>

#ALL Test
$group = [ADSI]"LDAP://OU=USERS,DC=domain,DC=NET"
#$group = [ADSI]"LDAP://CN=ALTX.Data.Maint,OU=Distribution
Lists,OU=CH,DC=echristus,DC=NET"
foreach($member in $group.member)
{
$user = [ADSI]"LDAP://$member"
Write-Host ("First Name:{0}" -f ($user.givenName).ToString())
Write-Host ("Last Name:{0}" -f ($user.sn).ToString())
Write-Host ("Display Name:{0}" -f ($user.Displayname).ToString())
Write-Host ("Email:{0}" -f ($user.mail).ToString())
Write-Host
}
My System SpecsSystem Spec
Old 09-11-2007   #10 (permalink)
Brandon Shell


 
 

Re: Quest AD help

$group is suppose to be the DN of group, not a OU/CN.

"Ian_1" <fakeaddy@xxxxxx> wrote in message
news:BE1AC77C-34D9-4EA9-92B0-5159F2624477@xxxxxx
Quote:

> Like I wrote Brandon, it does nothing, just goes from one line to the
> next:
>
> PS C:\scripts> C:\scripts\All_Test.ps1
> PS C:\scripts>
>
> #ALL Test
> $group = [ADSI]"LDAP://OU=USERS,DC=domain,DC=NET"
> #$group = [ADSI]"LDAP://CN=ALTX.Data.Maint,OU=Distribution
> Lists,OU=CH,DC=echristus,DC=NET"
> foreach($member in $group.member)
> {
> $user = [ADSI]"LDAP://$member"
> Write-Host ("First Name:{0}" -f ($user.givenName).ToString())
> Write-Host ("Last Name:{0}" -f ($user.sn).ToString())
> Write-Host ("Display Name:{0}" -f ($user.Displayname).ToString())
> Write-Host ("Email:{0}" -f ($user.mail).ToString())
> Write-Host
> }
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Quest powershell v 1.2 PowerShell
How to i add Quest snappins ? PowerShell
Quest AD cmdlets RC1 PowerShell
Can't add Quest AD cmdlets PowerShell
Quest PMC Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46