Server Inventory by PowerShell

Hi,

I'm gathering my server inventory and I'm using the PowerShell Command below;

Get-ADComputer -Filter {OperatingSystem -Like "Windows *Server*"} -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack -Wrap -Auto

But I would like to add to this filter; Serial numbers and Server Models.

Would you please tell me what would be the command should I add onto this command so I can also gather the serial numbers and server models

April 29th, 2015 4:25am

Hello Grandotto,

get-wmiobject Win32_bios

 should help.

It provides

SMBIOSBIOSVersion : XXXX
Manufacturer      : LENOVO
Name              : Phoenix BIOS XXXX
SerialNumber      : XXXXXXX
Version           : LENOVO - XXXX

you need to use the remote wmi calls.

Regards,

Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 5:33am

You can use WMI, it may take a while to run though depending on how many servers you have - 

Get-ADComputer -Filter {Name -Like "Windows *Server*"} -Property OperatingSystem,OperatingSystemServicePack | Select Name,OperatingSystem,OperatingSystemServicePack,@{N="Serial";E={(gwmi -query "Select * from win32_bios" -ComputerName $_.Name).SerialNumber}},@{N="Model";E={(gwmi -query "Select * from win32_computersystem" -ComputerName $_.Name).Model}} | ft -Wrap -Auto

April 29th, 2015 5:34am

You should also check with your PC manufacturer about where they (if they do at all) store this information.

This can vary between vendors.

Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 9:07am

Why do you all insist on typing everything on one unreadable line?

Get-ADComputer -Filter {Name -Like "Windows *Server*"} -Property OperatingSystem,OperatingSystemServicePack |
    Select Name,OperatingSystem,OperatingSystemServicePack,
        @{N="Serial";E={(gwmi win32_bios -ComputerName $_.Name).SerialNumber}},
        @{N="Model";E={(gwmi Win32_computersystem -ComputerName $_.Name).Model}} |
   ft -Wrap -Auto
Isn't that easier to read and way easier to type?

April 29th, 2015 9:26am

Why do you all insist on typing everything on one unreadable line?

Get-ADComputer -Filter {Name -Like "Windows *Server*"} -Property OperatingSystem,OperatingSystemServicePack |
    Select Name,OperatingSystem,OperatingSystemServicePack,
        @{N="Serial";E={(gwmi win32_bios -ComputerName $_.Name).SerialNumber}},
        @{N="Model";E={(gwmi Win32_computersystem -ComputerName $_.Name).Model}} |
   ft -Wrap -Auto
Isn't that easier to read and way easier to type?
Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 9:29am

Not a complain but noting that it is much easier to read and edit if you break the line at the pipes and at commas or braces.

This is also easier:

$properties=@(
    'Name',
    'OperatingSystem',
    'OperatingSystemServicePack',
    @{N="Serial";E={(gwmi win32_bios -ComputerName $_.Name).SerialNumber}},
    @{N="Model";E={(gwmi Win32_computersystem -ComputerName $_.Name).Model}}
)

Get-ADComputer -Filter {OperatingSystem -Like "Windows *Server*"} -Properties OperatingSystem,OperatingSystemServicePack |
    Select $properties |
    Format-Table -Auto

Lots of options so there is no need to be hammered into a single line.

If you really like compact then you can now do this.

Get-ADComputer -Filter 'OperatingSystem -Like "Windows *Server*"' -Properties * |Select $properties | ft -Auto

April 29th, 2015 9:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics