Hi Raymond,

Would the following work?

Test-Connection -computername (Get-ADDomainController -Filter * | Select-Object 
-ExpandProperty name)

Regards,

Fabio.

De: listsadmin@lists.myitforum.com [mailto:listsadmin@lists.myitforum.com] Em 
nome de Raymond Peng
Enviada em: sexta-feira, 6 de maio de 2016 19:02
Para: powersh...@lists.myitforum.com
Assunto: [powershell] pipe list of DCs, gather name, and ping, return list of 
DC with corresponding IP

Hi All,

I'm new to PS and learning as I go. I want to gather a list of domain 
controllers (instead of dsquery) and select just the names, run a ping test 1 
count to return the IP address, have a list of the DC with the IP in an 
organized way

So I gathered a list of DCs and names using the following: 
Get-ADDomainController -Filter * | Select-Object -Property name | 
test-connection
However when I try to pipe it to test-connection (ping)  it errors
I know it errors because it doesn't except pipeline input but then
Is there a way to make it work onscreen with another command?

I think I could export it to a list with just the computernames, get-content, 
and run test-connection -computername (get-content computers.txt)
But this failed as well

PS C:\Users\rpeng> $computers = Get-ADDomainController -Filter * | 
Select-Object -Property name
PS C:\Users\rpeng> $computers

PS C:\Users\rpeng> Get-ADDomainController -Filter * | select name > 
C:\data\computers.txt
PS C:\Users\rpeng> Get-Content C:\data\computers.txt

I feel I need to throw in a foreach command to run this properly
Any help is much appreciated, thanks!

name
----
WWDCWP01
NYDCWP01
TJDCWP01
WCDCWP01
MQDCWP01
KCCSDC01
KCDCWP02
PVDCWP01
SMDCWP02
NWDCWP01
TMDCWP03
KCDCWP01
SJDCWP01
IRDCWP01


PS C:\Users\rpeng> Test-Connection -ComputerName (Get-Content 
C:\data\computers.txt) -Count 1
Test-Connection : Cannot validate argument on parameter 'ComputerName'. The 
argument is null or empty. Provide an argument that is not null or empty, and 
then try the
command again.
At line:1 char:31
+ ... -Connection -ComputerName (Get-Content C:\data\computers.txt) -Count  ...
+                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Test-Connection], 
ParameterBindingValidationException
    + FullyQualifiedErrorId : 
ParameterArgumentValidationError,Microsoft.PowerShell.Commands.TestConnectionCommand

Thank you,

Ray






Reply via email to