Getting the Computer name, serial number and model from all connected PC..

This topic contains 9 replies, has 7 voices, and was last updated by Profile photo of Charles Webb Charles Webb 1 year ago.

  • Author
  • #31264
    Profile photo of Charles Webb
    Charles Webb

    I'm looking to obtain the computer name, serial number and model from a range of IP addresses(50-254). So far I managed to get the computer names but I'm stuck with the other two. Also there is any way to know when I got an error (like access denied) from which IP it was. Right now when I got that error the script continue to run but I have no clue which PC fail.

    Thank you,

  • #31266
    Profile photo of Chris Wolfenden
    Chris Wolfenden

    I would take a look at the Win32_BIOS and Win32_Baseboard classes (Get-WMIObject). Both have a serial number field but I have had better luck with Win32_BIOS. Win32_Baseboard will often continue manufacturer and model number.

    As far as determining which system an error came from you can try utilizing a try catch block. If you aren't familiar with error handling, there is a free ebook on this very site (


  • #31267
    Profile photo of ertuu85


    you could try something like

    $list = get-content .\IP_list.txt

    foreach($svr in $list)
    (get-WmiObject -ComputerName $svr win32_computersystem).name
    (get-WmiObject -ComputerName $svr win32_computersystem).model
    (Get-WmiObject -Computername $svr win32_bios).serialnumber

  • #31268
    Profile photo of Cyril Muffat
    Cyril Muffat

    you should take a look at Don Jones freebook

    he provides a bunch of examples with wmi that can help you

  • #31269
    Profile photo of Don Jones
    Don Jones

    Win32_ComputerSystem will usually have Manufacturer and Model, also.

  • #31270
    Profile photo of Don Jones
    Don Jones

    And if you're interested "Learn PowerShell Toolmaking in a Month of Lunches" uses pretty much what you're after as its running example.

  • #31273
    Profile photo of Charles Webb
    Charles Webb

    This is where I'm right now..
    $oct4 = 50..254
    foreach ($oct_a in $octet4) {

    if (Test-Connection "10.131.199.$oct_a" -Count 1 -Quiet) {

    $Computers=Get-WmiObject Win32_ComputerSystem -ComputerName "10.131.199.$octb" -ErrorAction ignore | Select-Object -ExpandProperty name
    $Computers | Export-Csv -Path computers.csv

    } #end if

    } #End foreach

    Cyril I download the book and I'm reading it shortly

  • #31297
    Profile photo of Mike Eyler
    Mike Eyler

    Try this 🙂

    $IP = "10.131.199."
    $Subnet = 50
    $Address = $IP+$subnet

    Test-Connection $Address -Count 1
    Get-WmiObject Win32_ComputerSystem -ComputerName $Address | select name,model
    Get-WmiObject Win32_BIOS -ComputerName $Address | select serialnumber
    $Address = $IP+$subnet
    }While($Subnet -le 254)

  • #31298
    Profile photo of Bob McCoy
    Bob McCoy

    Was that a typo? You're putting your range in $oct4 but iterating over $octet4. Your iterator is $oct_a, but then you're using $octb (undefined) as the last octet in the address.

  • #31314
    Profile photo of Charles Webb
    Charles Webb

    Thank you Mike, it works like a charm.
    Bob, Yes, it was a typo.. Thank you though..

You must be logged in to reply to this topic.