Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Listing all objects in an ADSI OU

Closed Thread
 
Thread Tools Display Modes
Old 05-30-2007   #1 (permalink)
techjohnny@gmail.com
Guest


 

Listing all objects in an ADSI OU

I'm trying to pull a list of computers from an OU in AD. I know to
use the [ADSI] object, but can't figure out where to go from there.
I'd like to use this list of computers to -filter for 1-process on all
computers.

Thanks,

--TJ

Old 05-30-2007   #2 (permalink)
RichS
Guest


 

RE: Listing all objects in an ADSI OU

$ou = [ADSI]"LDAP://OU=Workstations,DC=starking,DC=org"
foreach ($child in $ou.psbase.Children )
{
if ($child.ObjectCategory -like '*computer*'){Write-Host
$child.distinguishedname }

}

--
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


"techjohnny@gmail.com" wrote:

> I'm trying to pull a list of computers from an OU in AD. I know to
> use the [ADSI] object, but can't figure out where to go from there.
> I'd like to use this list of computers to -filter for 1-process on all
> computers.
>
> Thanks,
>
> --TJ
>
>

Old 05-30-2007   #3 (permalink)
techjohnny@gmail.com
Guest


 

Re: Listing all objects in an ADSI OU

How can I string everything but the computername?

--TJ

On May 30, 11:53 am, RichS <R...@discussions.microsoft.com> wrote:
> $ou = [ADSI]"LDAP://OU=Workstations,DC=starking,DC=org"
> foreach ($child in $ou.psbase.Children )
> {
> if ($child.ObjectCategory -like '*computer*'){Write-Host
> $child.distinguishedname }
>
> }
>
> --
> 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
>
>
>
> "techjoh...@gmail.com" wrote:
> > I'm trying to pull a list of computers from an OU in AD. I know to
> > use the [ADSI] object, but can't figure out where to go from there.
> > I'd like to use this list of computers to -filter for 1-process on all
> > computers.

>
> > Thanks,

>
> > --TJ- Hide quoted text -

>
> - Show quoted text -



Old 05-30-2007   #4 (permalink)
techjohnny@gmail.com
Guest


 

Re: Listing all objects in an ADSI OU

ACtually, I would like to list ONLY the computer names.

Thanks,

--TJ

On May 30, 12:57 pm, "techjoh...@gmail.com" <techjoh...@gmail.com>
wrote:
> How can I string everything but the computername?
>
> --TJ
>
> On May 30, 11:53 am, RichS <R...@discussions.microsoft.com> wrote:
>
>
>
> > $ou = [ADSI]"LDAP://OU=Workstations,DC=starking,DC=org"
> > foreach ($child in $ou.psbase.Children )
> > {
> > if ($child.ObjectCategory -like '*computer*'){Write-Host
> > $child.distinguishedname }

>
> > }

>
> > --
> > 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

>
> > "techjoh...@gmail.com" wrote:
> > > I'm trying to pull a list of computers from an OU in AD. I know to
> > > use the [ADSI] object, but can't figure out where to go from there.
> > > I'd like to use this list of computers to -filter for 1-process on all
> > > computers.

>
> > > Thanks,

>
> > > --TJ- Hide quoted text -

>
> > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -



Old 05-30-2007   #5 (permalink)
RichS
Guest


 

Re: Listing all objects in an ADSI OU

Change the script to

$ou = [ADSI]"LDAP://OU=Workstations,DC=starking,DC=org"
foreach ($child in $ou.psbase.Children )
{
if ($child.ObjectCategory -like '*computer*')
{
Write-Host $child.Name
}

}
--
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


"techjohnny@gmail.com" wrote:

> ACtually, I would like to list ONLY the computer names.
>
> Thanks,
>
> --TJ
>
> On May 30, 12:57 pm, "techjoh...@gmail.com" <techjoh...@gmail.com>
> wrote:
> > How can I string everything but the computername?
> >
> > --TJ
> >
> > On May 30, 11:53 am, RichS <R...@discussions.microsoft.com> wrote:
> >
> >
> >
> > > $ou = [ADSI]"LDAP://OU=Workstations,DC=starking,DC=org"
> > > foreach ($child in $ou.psbase.Children )
> > > {
> > > if ($child.ObjectCategory -like '*computer*'){Write-Host
> > > $child.distinguishedname }

> >
> > > }

> >
> > > --
> > > 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

> >
> > > "techjoh...@gmail.com" wrote:
> > > > I'm trying to pull a list of computers from an OU in AD. I know to
> > > > use the [ADSI] object, but can't figure out where to go from there.
> > > > I'd like to use this list of computers to -filter for 1-process on all
> > > > computers.

> >
> > > > Thanks,

> >
> > > > --TJ- Hide quoted text -

> >
> > > - Show quoted text -- Hide quoted text -

> >
> > - Show quoted text -

>
>
>

Old 05-30-2007   #6 (permalink)
techjohnny@gmail.com
Guest


 

Re: Listing all objects in an ADSI OU

Thanks.

That worked properly.

--TJ

On May 30, 1:51 pm, RichS <R...@discussions.microsoft.com> wrote:
> Change the script to
>
> $ou = [ADSI]"LDAP://OU=Workstations,DC=starking,DC=org"
> foreach ($child in $ou.psbase.Children )
> {
> if ($child.ObjectCategory -like '*computer*')
> {
> Write-Host $child.Name
>
> }
> }
>
> --
> 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
>
>
>
> "techjoh...@gmail.com" wrote:
> > ACtually, I would like to list ONLY the computer names.

>
> > Thanks,

>
> > --TJ

>
> > On May 30, 12:57 pm, "techjoh...@gmail.com" <techjoh...@gmail.com>
> > wrote:
> > > How can I string everything but the computername?

>
> > > --TJ

>
> > > On May 30, 11:53 am, RichS <R...@discussions.microsoft.com> wrote:

>
> > > > $ou = [ADSI]"LDAP://OU=Workstations,DC=starking,DC=org"
> > > > foreach ($child in $ou.psbase.Children )
> > > > {
> > > > if ($child.ObjectCategory -like '*computer*'){Write-Host
> > > > $child.distinguishedname }

>
> > > > }

>
> > > > --
> > > > 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

>
> > > > "techjoh...@gmail.com" wrote:
> > > > > I'm trying to pull a list of computers from an OU in AD. I know to
> > > > > use the [ADSI] object, but can't figure out where to go from there.
> > > > > I'd like to use this list of computers to -filter for 1-process on all
> > > > > computers.

>
> > > > > Thanks,

>
> > > > > --TJ- Hide quoted text -

>
> > > > - Show quoted text -- Hide quoted text -

>
> > > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -



Old 05-30-2007   #7 (permalink)
Dmitry Sotnikov


  DSotnikov is offline

Or use the AD cmdlets

Alternatively you can get the computer list with this AD cmdlet one-liner:

Get-QADComputer -SearchRoot ps64.local/TestOU

See this post for more OU-related operations: OU Management with PowerShell « Dmitry’s PowerBlog

Dmitry


Dmitry’s PowerBlog
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frustrating ADSI Stephan Winkler PowerShell 9 02-12-2007 09:07 AM
ADSI Documentation? Jim Holbach PowerShell 3 10-15-2006 08:01 PM
Trapping and ADSI? Dan Metzler PowerShell 19 10-09-2006 01:12 PM
[ADSI] Syntax Chris Warwick PowerShell 8 09-30-2006 12:13 AM
[ADSI] getting COM properties . /\\/\\o\\/\\/ [MVP] PowerShell 0 09-29-2006 11:36 AM








Vistax64.com 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 2005-2008

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 47 48 49 50