Sunday, July 15, 2007

get maching info What’s that machine called

“Captain Literal”.NET » What’s that machine called

D:\PsScripts]36> . .\networkTools.ps1# Create a CSV file, just like Mamood has[D:\PsScripts]38> “MachineName”, “machine1″, ” machine2″, ” machine3″, ” machine4″ > machineList.csv# Get machine information from DNS[D:\PsScripts]40> $machines = @();[D:\PsScripts]41> import-csv machineList.csv % { $machineInfo = resolve-hostByName $_.MachineName; $machines += New-MachineObject $machineInfo.Hostname $machineInfo.AddressList[0] }# Ping each host to get alive status[D:\PsScripts]43> $machines % { $_.Alive = Get-AliveStatus $_.HostName }# Get MAC Address for each alive host[D:\PsScripts]45> $machines ? { $_.Alive } % { $_.MacAddress = Get-MacAddressForHost $_.HostName $_.IpAddress }# Finally, output as a table (or you could export to CSV if you prefer)[D:\PsScripts]47> $machines ftHostName IpAddress MacAddress Alive——– ——— ———- —–machine1.captainliteral.net 192.168.8.3 00:04:FF:0B:23:B2 Truemachine2.captainliteral.net 192.168.8.8 Falsemachine3.captainliteral.net 192.168.7.1 Falsemachine4.captainliteral.net 192.168.8.5 00:16:17:0E:23:B2 True
And that’s that.

No comments: