Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

PowerShell Test-connection and Active Directory Input

$
0
0

I am just learning powershell, and I"m working to write a script that pulls computer names from AD and puts them into a Test-connection cmdlet to determine if its valid.

clear-host
import-module activedirectory
$workstations = Get-ADComputer -Filter '*' -SearchBase "OU=CMSD,OU=Windows XP,OU=Workstations,DC=TECH,DC=LOCAL" | FT Name
Foreach($w in $workstations)
    {
        Test-Connection -ComputerName $w -Count 1
    }

when i run the script, i receive the following error for all entries:

Test-Connection : Testing connection to computer 'Microsoft.PowerShell.Commands.Internal.Format.GroupEndData' failed: The requested name is valid, but no data of the requested type was found
At line:6 char:24+         Test-Connection <<<<  -computername $w -Count 1+ CategoryInfo          : ResourceUnavailable: (Microsoft.Power...at.GroupEndData:String) [Test-Connection], PingException+ FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand

I'm thinking that when the array is going into the Test-connection cmdlet, its adding string characters such as "name=computer" and not just the computer name.  I don't know how to edit strings in powershell.  

any help is appreciated, thank you.



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>