Fetch Networking Information from remote Windows Computers
Create a text file named servers.txt and put all servers in the file (one server at one line)
Copy and paste the below code (in Blue) in a text file and save it as IP_Details.PS1 and and put both servers.txt and IP_Details.ps1 at the same location.
Execute the script from powershell console as .\IP_Details.ps1
(Get-Content .\Servers.txt)| ForEach {
$SrvName = $_
If (Test-Connection -ComputerName $SRVName -Count 1 -Quiet) {
$csp = Get-WmiObject Win32_ComputerSystemproduct -Computername $SrvName
$cs = Get-WmiObject Win32_ComputerSystem -ComputerName $SRVName
$Nic = Get-WmiObject -computername $SRVName -Class win32_networkadapterconfiguration -Filter ipenabled='true'|select DHCPEnabled,IPAddress,IPSubnet,DefaultIPGateway
$props = @{
ComputerName = $SRVName
Domain = $cs.Domain
IPAdd = $NIC.IpAddress
Subnet = $NIC.IPSubnet
Gateway = $Nic.DefaultiPGateway
Platform = $Csp.Name
Vendor = $CSp.Vendor
}
New-Object PsObject -Property $props
} Else {
Write-Warning "$SRVName cannot be reached, skipping."
}
} | Sort ComputerName |
Select ComputerName,Platform,Vendor,Domain,@{N='IPAddress';E={[string]::join(".",($_.IPAdd))}},@{N='SubnetMask';E={[string]::join(".",($_.subnet))}},@{N='DefaultGateway';E={[string]::join(".",($_.Gateway))}} |
Export-csv -notypeinformation ComputerDetails.csv
Wait for the script to finish and a csv file will be ready with all the information at the same location where script is located.
Create a text file named servers.txt and put all servers in the file (one server at one line)
Copy and paste the below code (in Blue) in a text file and save it as IP_Details.PS1 and and put both servers.txt and IP_Details.ps1 at the same location.
Execute the script from powershell console as .\IP_Details.ps1
(Get-Content .\Servers.txt)| ForEach {
$SrvName = $_
If (Test-Connection -ComputerName $SRVName -Count 1 -Quiet) {
$csp = Get-WmiObject Win32_ComputerSystemproduct -Computername $SrvName
$cs = Get-WmiObject Win32_ComputerSystem -ComputerName $SRVName
$Nic = Get-WmiObject -computername $SRVName -Class win32_networkadapterconfiguration -Filter ipenabled='true'|select DHCPEnabled,IPAddress,IPSubnet,DefaultIPGateway
$props = @{
ComputerName = $SRVName
Domain = $cs.Domain
IPAdd = $NIC.IpAddress
Subnet = $NIC.IPSubnet
Gateway = $Nic.DefaultiPGateway
Platform = $Csp.Name
Vendor = $CSp.Vendor
}
New-Object PsObject -Property $props
} Else {
Write-Warning "$SRVName cannot be reached, skipping."
}
} | Sort ComputerName |
Select ComputerName,Platform,Vendor,Domain,@{N='IPAddress';E={[string]::join(".",($_.IPAdd))}},@{N='SubnetMask';E={[string]::join(".",($_.subnet))}},@{N='DefaultGateway';E={[string]::join(".",($_.Gateway))}} |
Export-csv -notypeinformation ComputerDetails.csv
Wait for the script to finish and a csv file will be ready with all the information at the same location where script is located.
Fastidious answer back in return of this matter with
ReplyDeletegenuine arguments and telling all concerning that.