Machine Inventory

Some addition to the server Inventory, now a machine inventory

This scripts collects processor,operatingsystem and computersystem information from 1 of more machines.

Commandline : <script.ps1> -servers <machine1>,<machine2>,…..

 

[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True,Position=1)]
   [array]$Servers
   )

$totalInvent = @()
foreach ($Server in $Servers){
    $cpu = gwmi win32_processor -ComputerName $Server
    $OS = gwmi win32_operatingsystem -ComputerName $Server
    $system = gwmi win32_computersystem -ComputerName $Server
    $obj = New-Object System.Object
    $obj | Add-Member -MemberType NoteProperty -Name "System" -Value $OS.CSName
    $obj | Add-Member -MemberType NoteProperty -Name "Domain" -Value $system.domain
    $obj | Add-Member -MemberType NoteProperty -Name "OS" -Value $OS.Caption
    $obj | Add-Member -MemberType NoteProperty -Name "Windir" -Value $OS.WindowsDirectory
    $obj | Add-Member -MemberType NoteProperty -Name "CPU #" -Value $system.NumberOfProcessors
    $obj | Add-Member -MemberType NoteProperty -Name "CPU Cores" -Value $CPU.NumberOfCores
    $obj | Add-Member -MemberType NoteProperty -Name "CPU Model" -Value $CPU.Name
    $obj | Add-Member -MemberType NoteProperty -Name "SystemType" -Value $System.SystemType
    $obj | Add-Member -MemberType NoteProperty -Name "Memory GB" -Value ([Math]::Round(($System.TotalPhysicalMemory[0] /1GB),4))
    $obj | Add-Member -MemberType NoteProperty -Name "InstallDate" -Value (([WMI] "").ConvertToDateTime(($OS).InstallDate)).ToShortDateString()
    $obj | Add-Member -MemberType NoteProperty -Name "Description" -Value $OS.Description
    $totalInvent += $obj
    }
$totalInvent | Out-GridView -Title "Server Inventory" -OutputMode multiple

Console Output :

MachineInventory-Console

MachineInventory-Gridview

 

 

About the Author

wvsandwijk

I am a Technical Specialist - Cloud Infrastructures from the Netherlands. My Skills are mainly PowerShell, VMWare, Hyper-V, Microsoft System Center products and Windows Azure Pack. I work for a company in Utrecht The Netherlands.

No Comments

Comments are closed.