![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | [newbee] Search In AD (GC) Hello, I start with PS ... And I wonder how can i execute this script for quering a GC instead of a DC. $root = [ADSI]'' $searcher = new-object System.DirectoryServices.DirectorySearcher($root) $searcher.filter = "(&(objectClass=user)(sn="+$ligne."First Name"+") (givenName="+$ligne."Last Name"+"))" $user = $searcher.findall() $user Then, how can I print total of $user ? Such as $user.count and return me number of lines... Thanks ![]() -- P.A. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: [newbee] Search In AD (GC) For GC Change $root $root = ([ADSI]"GC://rootDSE").defaultNamingContext As for the count. $user.count works for me. "BZP" <p.audonnet@xxxxxx> wrote in message news:1188320657.194680.225920@xxxxxx Quote: > Hello, > > I start with PS ... And I wonder how can i execute this script for > quering a GC instead of a DC. > > $root = [ADSI]'' > $searcher = new-object > System.DirectoryServices.DirectorySearcher($root) > $searcher.filter = "(&(objectClass=user)(sn="+$ligne."First Name"+") > (givenName="+$ligne."Last Name"+"))" > $user = $searcher.findall() > $user > > Then, how can I print total of $user ? Such as $user.count and return > me number of lines... > > Thanks ![]() > > -- > P.A. > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: [newbee] Search In AD (GC) You can use the GC:// moniker <moniker://distinguishedName> GC://ou=ouname,dc=domain,dc=com Shay http://scriptolog.blogspot.com Quote: > Hello, > > I start with PS ... And I wonder how can i execute this script for > quering a GC instead of a DC. > > $root = [ADSI]'' > $searcher = new-object > System.DirectoryServices.DirectorySearcher($root) > $searcher.filter = "(&(objectClass=user)(sn="+$ligne."First Name"+") > (givenName="+$ligne."Last Name"+"))" > $user = $searcher.findall() > $user > Then, how can I print total of $user ? Such as $user.count and return > me number of lines... > > Thanks ![]() > > -- > P.A. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: [newbee] Search In AD (GC) It would be worth having a look at the Quest AD cmdlets. They make working with AD very much easier -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Shay Levi" wrote: Quote: > You can use the GC:// moniker > <moniker://distinguishedName> > GC://ou=ouname,dc=domain,dc=com > > > Shay > http://scriptolog.blogspot.com > > > Quote: > > Hello, > > > > I start with PS ... And I wonder how can i execute this script for > > quering a GC instead of a DC. > > > > $root = [ADSI]'' > > $searcher = new-object > > System.DirectoryServices.DirectorySearcher($root) > > $searcher.filter = "(&(objectClass=user)(sn="+$ligne."First Name"+") > > (givenName="+$ligne."Last Name"+"))" > > $user = $searcher.findall() > > $user > > Then, how can I print total of $user ? Such as $user.count and return > > me number of lines... > > > > Thanks ![]() > > > > -- > > P.A. > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Search In AD (GC) On 28 août, 19:50, "Brandon Shell" <tshell.m...@xxxxxx> wrote: Quote: > For GC Change $root > $root = ([ADSI]"GC://rootDSE").defaultNamingContext > > As for the count. > $user.count works for me. > > "BZP" <p.audon...@xxxxxx> wrote in message > > news:1188320657.194680.225920@xxxxxx > > > Quote: > > Hello, Quote: > > I start with PS ... And I wonder how can i execute this script for > > quering a GC instead of a DC. Quote: > > $root = [ADSI]'' > > $searcher = new-object > > System.DirectoryServices.DirectorySearcher($root) > > $searcher.filter = "(&(objectClass=user)(sn="+$ligne."First Name"+") > > (givenName="+$ligne."Last Name"+"))" > > $user = $searcher.findall() > > $user Quote: > > Then, how can I print total of $user ? Such as $user.count and return > > me number of lines... Quote: > > Thanks ![]() Quote: > > -- > > P.A.- Masquer le texte des messages précédents - > - Afficher le texte des messages précédents - Perfect. Thanks. -- P.A. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Windows Vista ultimate x64 Search engine issues - Search fails to index | Vista General | |||
| newbee needs help with IIS 6.0 migration | PowerShell | |||
| Help for a newbee and sorry if I've not put in correct place, etc | Vista mail | |||
| Newbee question - advise | Vista General | |||
| Newbee! Skills Required? | PowerShell | |||