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 - [newbee] Search In AD (GC)

Reply
 
Old 08-28-2007   #1 (permalink)
BZP


 
 

[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 SpecsSystem Spec
Old 08-28-2007   #2 (permalink)
Brandon Shell


 
 

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 SpecsSystem Spec
Old 08-28-2007   #3 (permalink)
Shay Levi


 
 

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 SpecsSystem Spec
Old 08-28-2007   #4 (permalink)
RichS


 
 

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 SpecsSystem Spec
Old 08-29-2007   #5 (permalink)
BZP


 
 

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 SpecsSystem Spec
Reply

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


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