#requires -version 3.0
###############################################################################
# Copyright (c) 201x-2018 leedesmond.com
# All Rights Reserved. Use at your own risk and responsibility.
# Version 1.00
#
# Any Windows Server – Always Up-to-date Hardware Inventory (Core)
#
# REQUIREMENTS: PowerShell Remoting enabled on target hosts & firewall
# ports (WMI calls)
###############################################################################
#get Lync/Skype4b Registrar pools and corresponding nodes in this example
$pools = (Get-CsService -Registrar | ? SiteId -eq “Site:CH”).PoolFqdn
$nodes = $pools | % { Get-CsComputer -Pool $_ }
#retrieve Fqdn of nodes or manually assign an array of host names
$computers = $nodes.Fqdn
#remote #powershell to gather core hardware inventory
$hw = Invoke-Command -ComputerName $computers `
-Command {
$ram = Get-CimInstance CIM_PhysicalMemory | Select *
$disk = Get-CimInstance CIM_LogicalDisk | Select *
$cpu = Get-CimInstance CIM_Processor | Select *
$bios = Get-CimInstance Win32_BIOS | Select *
$net = gcim Win32_NetworkAdapterConfiguration | Select *
[pscustomobject]@{ram=$ram;disk=$disk;cpu=$cpu;bios=$bios;net=$net}
}
#process into usable format
$arr = @()
foreach ($c in $hw)
{
$cpucnt = $c.cpu | Measure -Sum -Property NumberOfCores
$net = $c.net | ? IPEnabled
$disk = $c.disk | ? DriveType -eq 3 #get fixed hard disk type only
$obj = New-Object PsObject
$obj | Add-Member -MemberType NoteProperty -Name PsComputerName `
-Value $c.PsComputerName
$obj | Add-Member -MemberType NoteProperty -Name CPUNumberOfCores `
-Value $($c.cpu[0].NumberOfCores)
$obj | Add-Member -MemberType NoteProperty -Name CPUNumberOfCPU `
-Value $($cpucnt.count)
$obj | Add-Member -MemberType NoteProperty -Name CPUNumberOfCoresTot `
-Value $($cpucnt.sum)
$obj | Add-Member -MemberType NoteProperty -Name ‘RAM(GB)’ `
-Value $(($c.ram | Measure -Sum -Property Capacity).sum/1gb)
$obj | Add-Member -MemberType NoteProperty -Name NETIndex -Value $($net.index)
$obj | Add-Member -MemberType NoteProperty -Name NETDescription `
-Value $($net.Description)
$obj | Add-Member -MemberType NoteProperty -Name NETIPAddress `
-Value $($net.IPAddress)
$obj | Add-Member -MemberType NoteProperty -Name NETIPSubnet `
-Value $($net.IPSubnet)
$obj | Add-Member -MemberType NoteProperty -Name NETDefaultIPGateway `
-Value $($net.DefaultIPGateway)
$obj | Add-Member -MemberType NoteProperty -Name NETDNSDomainSuffixSearchOrder `
-Value $($net.DNSDomainSuffixSearchOrder)
foreach ($d in $disk)
{
$did = $d.DeviceID.SubString(0,1);
$obj | Add-Member -MemberType NoteProperty -Name `
“DiskDeviceID$($did)” -Value $d.DeviceID
$obj | Add-Member -MemberType NoteProperty -Name `
“DiskFreeSpace$($did)(GB)” -Value (($d.FreeSpace)/1gb)
$obj | Add-Member -MemberType NoteProperty -Name `
“DiskSize$($did)(GB)” -Value (($d.Size)/1gb)
$obj | Add-Member -MemberType NoteProperty -Name `
“DiskFileSystem$($did)” -Value $d.FileSystem
$obj | Add-Member -MemberType NoteProperty -Name `
“DiskVolumeName$($did)” -Value $d.VolumeName
$obj | Add-Member -MemberType NoteProperty -Name `
“DiskVolumeSerialNumber$($did)” `
-Value $d.VolumeSerialNumber
}
$obj | Add-Member -MemberType NoteProperty -Name BIOSName `
-Value $c.bios.Name
$obj | Add-Member -MemberType NoteProperty -Name BIOSManufacturer `
-Value $c.bios.Manufacturer
$obj | Add-Member -MemberType NoteProperty -Name BIOSVersion `
-Value $c.bios.Version
$obj | Add-Member -MemberType NoteProperty -Name BIOSSerialNumber `
-Value $c.bios.SerialNumber
$obj | Add-Member -MemberType NoteProperty -Name BIOSReleaseDate `
-Value $c.bios.ReleaseDate
$arr += $obj
}
$arr | ogv -Title “leedesmond.com Core Hardware Inventory ($($arr.count))”