locked
how to get multiple IP address's on remote servers RRS feed

  • Question

  • Hello,

    I am trying to create a ps script that prompts for a server name, and then retrieves all the IP address's on that remote server.
    This is what I have tried so far, but it only list one ip address on that remote server.

    #promp for server name
    #list all ip address's

    $computerList = Read-Host 'Enter computer name'
    foreach ($computer in $computerList) {
    Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -Computer . | Format-Table -Property IPAddress}

    If I RDP into the server directly, and run ipconfig on the server itself, I get all the listed ip address's.
    But this does not helpful, since I need the script to grab the ip address's remotely.

    I appreciate any feed back!
    Thanks
    Quail Farmer

    Monday, February 26, 2018 7:28 PM

All replies

  • You are not suing the computer name in your WMI call.  You just have a dot where the name belongs.


    \_(ツ)_/

    Monday, February 26, 2018 7:31 PM
  •  Get-WmiObject Win32_NetworkAdapterConfiguration -Filter 'IPEnabled=TRUE' -Computer $computer | select -expand IPAddress


    \_(ツ)_/


    Monday, February 26, 2018 7:33 PM
  • Thank you, that worked!

    Monday, February 26, 2018 8:01 PM
  • Hello,

    Is there a ps command to get the network adapter names?

    the Get-Netadapter cmdlet is not available, and I also need to include a way to verify IP address and network adapter names in the script.

    thanks again

    Monday, February 26, 2018 8:23 PM
  • Get-WmiObject Win32_NetworkAdapter | select name

    \_(ツ)_/

    Monday, February 26, 2018 8:27 PM
  • Hello,
    Thanks for your quick response, but that command does not return the network adapters name. My network adapter is named: MYIP

    when I run the following command, it does not display the "MYIP" network adapter name.
    Get-WmiObject Win32_NetworkAdapter | select name

    name                                       
    ----                                       
    WAN Miniport (SSTP)                        
    WAN Miniport (IKEv2)                       
    WAN Miniport (L2TP)                        
    WAN Miniport (PPTP)                        
    WAN Miniport (PPPOE)                       
    WAN Miniport (IPv6)                        
    WAN Miniport (Network Monitor)             
    Intel(R) 82579LM Gigabit Network Connection
    WAN Miniport (IP)                          
    Juniper Network Connect Virtual Adapter    
    RAS Async Adapter 

    My ps version is:5.1.14409.1012, does this version have some limitations?

    Thanks again,

    QF

    Tuesday, February 27, 2018 5:13 PM
  • Learn to use Get-Member and "select *" to find the proeprties you want.

    Get-WmiObject Win32_NetworkAdapter | select name, NetConnectionID


    \_(ツ)_/

    Tuesday, February 27, 2018 5:18 PM
  • That works, thanks again!
    Tuesday, February 27, 2018 7:27 PM
  • Hi,

    I'm checking how the issue is going, was your issue resolved?

    And if the replies as above are helpful, we would appreciate you to mark them as answers, and if you resolve it using your own solution, please share your experience and solution here. It will be greatly helpful to others who have the same question.

    Appreciate for your feedback.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, February 28, 2018 1:58 AM
  • I tried several commands, but cannot retrieve the specific network adapter information for IP address, and adapter name:
    I am able to get network adapter name using this:
    Get-WmiObject win32_networkadapter -ComputerName servername | select NetConnectionID

    But this command returns a blank:
    Get-WmiObject win32_networkadapter -ComputerName servername| select IPAddress

    also, I am sure how to use: Get-member command for obtaining network adapter information.

    Thanks

    Thursday, March 1, 2018 10:04 PM
  • I gave you both answers above.  You need to go back and carefully read what I posted.


    \_(ツ)_/

    Thursday, March 1, 2018 10:21 PM
  • Thanks again, I was able retrieve specific remote server information using this script:

    #get OS verions
    #get volume disk space usage
    #get memory page swap usage
    #get ip 
    #get cpu
    #get NIC adapter names

    $computerList = Read-Host 'Enter computer name'


    foreach ($computer in $computerList) {
    Get-WmiObject -Computer $computer -Class Win32_OperatingSystem}
    ;
    foreach ($computer in $computerList) {
    get-wmiobject -computer $computer win32_logicaldisk -filter "drivetype=3" |
    ForEach-Object { Write-Host name : $_.deviceid; write-host Total space : ($_.size/1GB).tostring("0.00")GB; write-host Free Spce : ($_.freespace/1GB).tostring("0.00")GB }}
    ;
    foreach ($computer in $computerList) {
    Get-WmiObject Win32_PageFileusage -ComputerName $computer | Select-Object Name,AllocatedBaseSize,PeakUsage}
    ;
    foreach ($computer in $computerList) {
    Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $computer | Format-Table -Property IPAddress}
    ;
    foreach ($computer in $computerList) {
    Get-WmiObject –class Win32_processor | ft systemname,Name,DeviceID,NumberOfCores,NumberOfLogicalProcessors, Addresswidth}
    ;
    foreach ($computer in $computerList) {
    Get-WmiObject win32_networkadapter -ComputerName $computer | select name, netconnectionID}

    Tuesday, March 6, 2018 10:15 PM
  • Hi,

    Good to hear that you have solved this issue by yourself. In addition, thanks for sharing your solution in the forum as it would be helpful to anyone who encounters similar issues.

    If there is anything else we can do for you, please feel free to post in the forum.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, March 8, 2018 11:19 AM
  • Hi,

    Good to hear that you have solved this issue by yourself. In addition, thanks for sharing your solution in the forum as it would be helpful to anyone who encounters similar issues.

    If there is anything else we can do for you, please feel free to post in the forum.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Sorry, i cant help myself not to reply to your statement " thanks for sharing your solution in the forum as it would be helpful ..".

    You are not beginner (I consider myself as a beginner) and u should at least inform the user, that his latest script has many design flaws and this is the way how he should not script that.  It will prevent new scripters from bad habit.  

    Thursday, March 8, 2018 11:32 AM