Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum 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

Re: Computernames from AD without curly braces ??

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-10-2008   #1 (permalink)
Shay Levy [MVP]
Guest


 

Re: Computernames from AD without curly braces ??


other options you can use:

## get all domain dc's
$dom = [System.DirectoryServices.ActiveDirectory.Domain]::getcurrentdomain()
$dom.DomainControllers | select Name

## this will get the all dc's in the forest (same as the next one below)
## $dom.forest.domains | select -expand DomainControllers | select name,domain


## get all forest dc's
$forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$forest.domains | select -expand domainControllers | select name,domain



---
Shay Levy
Windows PowerShell MVP
blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic



SL> Hi Dennis,
SL>
SL> $dclist | select -expand name
SL>
SL> ---
SL> Shay Levy
SL> Windows PowerShell MVP
SL> blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic
D>> Is there a way to get the computers names from an OU in AD without
D>> the curly braces. I wrote this:
D>>
D>> $objADDCs = [adsi]"LDAP://OU=Domain
D>> Controllers,DC=corp,DC=scwa,DC=com"
D>> $dclist = $objADDCs.psbase.children
D>> $array = @{}
D>> foreach ($comp in $dclist) { $array.($comp.name) =
D>> denping($comp.name)}
D>> $array | ft
D>> And it outputs this:
D>> Name Value ----
D>> ----- {GRDC01} Alive
D>> {PCDC01} Alive {ERODC01}
D>> Alive {CRODC01} Alive
D>> {HAUPDC01} Alive {OAKDC02}
D>> Alive
D>>
D>> Is there a way to get the names without the quotes and without
D>> trimming the value of the name?
D>>



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab expansion on path's with square braces is broken Keith Hill [MVP] PowerShell 0 05-11-2007 11:46 PM


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 51