![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 Specs![]() |
| | #9 (permalink) |
| | 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 Specs![]() |
| | #10 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||