Here is the script.
[cmdletbinding()] param ( [parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [string[]]$ComputerName = $env:computername ) begin {} process { foreach ($Computer in $ComputerName) { if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) { $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | ? {$_.IPEnabled} foreach ($Network in $Networks) { $IPAddress = $Network.IpAddress[0] $SubnetMask = $Network.IPSubnet[0] $DefaultGateway = $Network.DefaultIPGateway $DNSServers = $Network.DNSServerSearchOrder $IsDHCPEnabled = $false If($network.DHCPEnabled) { $IsDHCPEnabled = $true } $MACAddress = $Network.MACAddress $OutputObj = New-Object -Type PSObject $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper() $OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress $OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask $OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value $DefaultGateway $OutputObj | Add-Member -MemberType NoteProperty -Name IsDHCPEnabled -Value $IsDHCPEnabled $OutputObj | Add-Member -MemberType NoteProperty -Name DNSServers -Value $DNSServers $OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress $OutputObj } } } } end {}I then used a txt file to input all the servers into the script. This was in the comments sections so I will add it in here..
"get-Content c:\temp\computers.txt | Get-IpDetails.ps1 | ft -auto where c:\temp\computers.txt is the file that contains computers list." I used this: get-Content .\computers.txt | .\Get-IpDetails.ps1 | ft -auto
Also remember that you are running a scriptlet so you need to set this unless you have something else done on your system.
Set-ExecutionPolicy Unrestricted
Enjoy.
Positive webpage, where did u think of the data on this posting?I have perused a couple of the articles on your site now, and I truly like your style. You rock and please keep up the successful work. what is my ip location
ReplyDelete