Code: Select all
function Get-sysinfo ($ComputerName)
{
$sysCompp = Get-WmiObject Win32_ComputerSystemProduct -ComputerName $ComputerName
$sysComp = Get-WmiObject Win32_ComputerSystem -ComputerName $ComputerName
$sysOS = Get-WmiObject Win32_OperatingSystem -ComputerName $ComputerName
$sysBIOS = Get-WmiObject Win32_BIOS -ComputerName $ComputerName
$sysCPU = Get-WmiObject Win32_Processor -ComputerName $ComputerName
$sysRAM = Get-WmiObject Win32_PhysicalMemory -ComputerName $ComputerName
$sysNAC = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $ComputerName -Filter "IPEnabled='True'"
$sysMon = Get-WmiObject Win32_DesktopMonitor -ComputerName $ComputerName
$sysVid = Get-WmiObject Win32_VideoController -ComputerName $ComputerName
$sysOD = Get-WmiObject Win32_CDROMDrive -ComputerName $ComputerName
$sysHD = Get-WmiObject Win32_LogicalDisk -ComputerName $ComputerName
$sysProc = Get-WmiObject Win32_Process -ComputerName $ComputerName
$sysinfo = @()
### General #####################################
$customobject = [pscustomobject]@{
Property = "Computer Name"
Value = "$($sysCompp.PSComputerName)"
Group = 'General'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "Last Restart"
Value = "$($sysOS.ConvertToDateTime($sysOS.LastBootUpTime))"
Group = 'General'
}
$sysinfo += $customobject
### Build Info #####################################
$customobject = [pscustomobject]@{
Property = "Manufactorer"
Value = "$($sysCompp.Vendor)"
Group = 'Build Info'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "Model"
Value = "$($sysCompp.Version)"
Group = 'Build Info'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "Name"
Value = "$($sysCompp.Name)"
Group = 'Build Info'
}
$sysinfo += $customobject
### Operating System #####################################
$customobject = [pscustomobject]@{
Property = "OS"
Value = "$($sysOS.Caption)"
Group = 'Operating System'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "Service Pack"
Value = "$($sysOS.CSDVersion)"
Group = 'Operating System'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "Version"
Value = "$($sysOS.Version)"
Group = 'Operating System'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "Version"
Value = "$($sysOS.Version)"
Group = 'Operating System'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "OS Architecture"
Value = "$($sysOS.OSArchitecture)"
Group = 'Operating System'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "Install Date"
Value = "$($sysOS.ConvertToDateTime($sysOS.InstallDate))"
Group = 'Operating System'
}
$sysinfo += $customobject
### Hardware #####################################
$customobject = [pscustomobject]@{
Property = "CPU"
Value = "$($sysCPU.Name)"
Group = 'Hardware'
}
$sysinfo += $customobject
$tRAM = "{0:N2} GB Usable - " -f $($sysComp.TotalPhysicalMemory / 1GB)
$sysRAM | %{ $tRAM += "[$($_.Capacity / 1GB)]" }
$customobject = [pscustomobject]@{
Property = "RAM"
Value = "$tRAM"
Group = 'Hardware'
}
$sysinfo += $customobject
$sysHD | Where-Object { $_.DriveType -eq 3 } | %{
$HDD++
$HDInfo = "{0} {1} {2:N1} GB Free / {3:N1} GB Total" -f $_.DeviceID, $_.FileSystem, ($_.FreeSpace / 1GB), ($_.Size / 1GB)
$customobject = [pscustomobject]@{
Property = "HD[$HDD]"
Value = "$HDInfo"
Group = 'Hardware'
}
$sysinfo += $customobject
}
$sysOD | %{
$OpDrive++
$customobject = [pscustomobject]@{
Property = "[$OpDrive++]Optical Drive"
Value = "$($sysOD.Drive) $($sysOD.Caption)"
Group = 'Hardware'
}
$sysinfo += $customobject
}
$Monitors = $null
$sysMON | %{ $Monitors += "[{0} x {1}] " -f $_.ScreenWidth, $_.ScreenHeight }
$customobject = [pscustomobject]@{
Property = "Monitor(s)"
Value = "$Monitors"
Group = 'Hardware'
}
$sysinfo += $customobject
## Network Adapters
$sysNAC | %{
$NAC++
$customobject = [pscustomobject]@{
Property = "Description[$NAC]"
Value = "$($_.Description)"
Group = 'Network Adapters'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "IPAddress[$NAC]"
Value = "$($_.IPAddress)"
Group = 'Network Adapters'
}
$sysinfo += $customobject
$customobject = [pscustomobject]@{
Property = "MACAddress[$NAC]"
Value = "$($_.MACAddress)"
Group = 'Network Adapters'
}
$sysinfo += $customobject
}
return $sysinfo
}
$info = Get-sysinfo $env:computername