Last active
September 8, 2017 17:26
-
-
Save armentpau/41290faae2451f9fb6a9bbb179c97b79 to your computer and use it in GitHub Desktop.
Test connectivity and convert ip to computer name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#TODO: Place custom script here | |
Import-Module Activedirectory | |
$preSearchComputer = "10.140.8.155" | |
foreach ($item in ([system.Net.dns]::GetHostByName($preSearchComputer)).AddressList.ipaddresstostring) | |
{ | |
if (Test-Connection -ComputerName $item -Count 1 -Quiet) | |
{ | |
$Computer = ([System.Net.Dns]::GetHostByAddress($item)).HostName | |
$system = Get-WmiObject Win32_ComputerSystem -ComputerName "$Computer" | Select-Object -property name | |
$networkResult = Get-WmiObject win32_networkadapterconfiguration -Filter 'ipenabled = "true"' -ComputerName $Computer | |
$os = Get-WmiObject Win32_OperatingSystem -ComputerName $Computer | |
$description = Get-ADComputer -Filter ('Name -like "*' + $($Computer.Split("."))[0] + '*"') -Property description | |
$Object = New-Object PSObject -Property @{ | |
'Name' = $system.Name | |
'IP Address' = $networkResult.IPAddress | |
'OS Caption' = $os.Caption | |
'Description' = $description.description | |
} | |
$richtextbox1.Text = $object.psobject.properties | Where-Object{ $_.membertype -eq "noteproperty" } | ForEach-Object{ | |
"$($_.name) - $($_.value)`r`n" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment