I'm trying to create a script that takes a list of a few hundred machines, and I'd like to have it output me three things: IP address, VMware version, and of course computername. I can't quite put it all together and thought I'd ask for help.
Below is what I have which outputs to a CSV file, but I'm not sure how to make it display the IP. I've tried some different syntax with "ping" but the script will hang on the first machine and never go past it.
for /f %%i in (C:\Temp\Computers.txt) do (
echo Software on %%i >> C:\Temp\psinfovmware15.csv
psinfo64 -s \\%%i | find /i "VMware" >> C:\Temp\psinfovmware15.csv
echo IP Address on %%i >> C:\Temp\psinfovmware15.csv
ping \\%%i >> C:\Temp\psinfovmware15.csv
)
excel C:\Temp\psinfovmware15.csv
Also, I found this powershell script below that displays the computername and IP address, but I'd like for it to display the VMware version:
$servers = Get-Content "computers.txt"
$report = @()
ForEach ($server in $servers) {
Try {
$tempreport = New-Object PSObject
$IP = ((Test-Connection -ea stop -Count 1 -comp $server).IPV4Address).IPAddresstoString
$tempreport | Add-Member NoteProperty Server $server
$tempreport | Add-Member NoteProperty Status "Up"
$tempreport | Add-Member NoteProperty IP $ip
$report += $tempreport
}
Catch {
$tempreport = New-Object PSObject
$tempreport | Add-Member NoteProperty Server $server
$tempreport | Add-Member NoteProperty Status "Down"
}
}
$report | Export-Csv -NoTypeInformation "report.csv"
Any ideas on how to have a timeout if the machine isn't on the network? Thanks!