Hallo zusammen,
ich bin im Netz über ein schönes Script gestolpert welches Rechner aus einer .csv liest und anpingt. Jedoch bekomme ich es nicht zum laufen. Kann mir hier einer helfen?
<# .SYNOPSIS Powershell script to ping all IP addresseses in a CSV file. .DESCRIPTION This PowerShell script reads a CSV file and pings all the IP addresses listed in the IPAddress column. .PARAMETER <csvfile> File name and path of the CSV file to read. .NOTES Version: 1.0 Author: Open Tech Guides Creation Date: 12-Jan-2017 .LINK www.opentechguides.com .EXAMPLE Ping-IPList C:\Users\***\Desktop\GroupCopy\IPaddressList.csv #> Param( [Parameter(Mandatory=$true, position=0)][string]$csvfile ) $ColumnHeader = "IPaddress" Write-Host "Reading file" $csvfile $ipaddresses = import-csv $csvfile | select-object $ColumnHeader Write-Host "Started Pinging.." foreach( $ip in $ipaddresses) { if (test-connection $ip.("IPAddress") -count 1 -quiet) { write-host $ip.("IPAddress") "Ping succeeded." -foreground green } else { write-host $ip.("IPAddress") "Ping failed." -foreground red } } Write-Host "Pinging Completed."
Es wird folgender Fehler ausgeworfen:
Test-Connection : Das Argument für den Parameter "ComputerName" kann nicht überprüft werden. Das Argument
ist NULL oder leer. Geben Sie ein Argument an, das nicht NULL oder leer ist, und führen Sie den Befehl erneut aus. In Zeile:36 Zeichen:25 + if (test-connection $ip.("IPAddress") -count 1 -quiet) {
+
~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Test-Connection], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.TestConnectionCommand
Vielen Dank schon mal und Grüße :)