Erwin Pombett
asked on
how can i display the values that Get-ADDomainController asnwers in a foreach ?
Hello experts,
i'm trying to get values out of the response of Get-ADDomainController but i dont succeed inside a foreach.
what am I doing wrong, i only receive three times the domain but no ip nor name.
here's what i wrote so far.
foreach($server in (Get-ADForest).globalcatal ogs){
foreach-object { 'server : {0, 20} --- IP : {0, 20} --- Name: {0, 20}' -f
$(Get-ADDomainController -Server $server).Domain ,
$(Get-ADDomainController -Server $server).IPv4Address,
$(Get-ADDomainController -Server $server).Name
}
}
thank you in advance.
toshi.
i'm trying to get values out of the response of Get-ADDomainController but i dont succeed inside a foreach.
what am I doing wrong, i only receive three times the domain but no ip nor name.
here's what i wrote so far.
foreach($server in (Get-ADForest).globalcatal
foreach-object { 'server : {0, 20} --- IP : {0, 20} --- Name: {0, 20}' -f
$(Get-ADDomainController -Server $server).Domain ,
$(Get-ADDomainController -Server $server).IPv4Address,
$(Get-ADDomainController -Server $server).Name
}
}
thank you in advance.
toshi.
ASKER
;)
i'm begining with powershell, i'll keep your solution in mind ;)
thanks a lot.
i'm begining with powershell, i'll keep your solution in mind ;)
thanks a lot.
ASKER
what about string controlling as i was trying to do ?
i'd like to have the responses more close one to each other.
i'd like to have the responses more close one to each other.
ASKER
i'm trying to display with string format but i dont knwo where to it ?
i'm having error with the following line
foreach($server in (Get-ADForest).globalcatal ogs){
get-addomaincontroller -server $server | select '{0. 20}, -- {1, 20}, {2, 20} ' -f domain, ipv4address, name
}
i'm having error with the following line
foreach($server in (Get-ADForest).globalcatal
get-addomaincontroller -server $server | select '{0. 20}, -- {1, 20}, {2, 20} ' -f domain, ipv4address, name
}
ASKER
not in such way either....
foreach($server in (Get-ADForest).globalcatal ogs){
get-addomaincontroller -server $server | select domain, ipv4address, name | '{0. 20}, -- {1, 20}, {2, 20}' -f domain, ipv4address, name
}
foreach($server in (Get-ADForest).globalcatal
get-addomaincontroller -server $server | select domain, ipv4address, name | '{0. 20}, -- {1, 20}, {2, 20}' -f domain, ipv4address, name
}
This should accomplish that adjustment...
foreach($server in (Get-ADForest).globalcatalogs){
get-addomaincontroller -server $server | format-table domain, ipv4address, name -autosize
}
ASKER
thank again, but autosize is not creating columns with the results...
can you help me with formating the result ?
how to get the result and play with {0,20} ?
toshi
can you help me with formating the result ?
how to get the result and play with {0,20} ?
toshi
Oh, I see...
So, try this instead of your original script:
So, try this instead of your original script:
foreach($server in (Get-ADForest).globalcatalogs){
$dc = get-addomaincontroller -server $server
'server : {0, 20} --- IP : {0, 20} --- Name: {0, 20}' -f $dc.domain, $dc.ipv4address, $dc.name
}
ASKER
thank for your quick reply,
this display is the same that i started with .....only the domain name is display three times .
this display is the same that i started with .....only the domain name is display three times .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
youuuuuu rooock !
thanks a lot !
thanks a lot !
Glad I could help. :^)
Open in new window