Advertisement
Lee_Dailey

SysInfo_example_for_anima-vero-quaerenti

May 16th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #requires -RunAsAdministrator
  2.  
  3. # fake reading in a list of computer names
  4. #    in real life, use Get-Content or (Get-ADComputer).Name
  5. $ComputerList = @'
  6. Localhost
  7. BetterNotBeThere
  8. 127.0.0.1
  9. 10.0.0.1
  10. ::1
  11. '@.Split("`n").Trim("`r")
  12.  
  13. $IC_ScriptBlock = {
  14.     $CIM_ComputerSystem = Get-CimInstance -ClassName CIM_ComputerSystem
  15.     $CIM_BIOSElement = Get-CimInstance -ClassName CIM_BIOSElement
  16.     $CIM_OperatingSystem = Get-CimInstance -ClassName CIM_OperatingSystem
  17.     $CIM_Processor = Get-CimInstance -ClassName CIM_Processor
  18.     $CIM_LogicalDisk = Get-CimInstance -ClassName CIM_LogicalDisk |
  19.         Where-Object {$_.Name -eq $CIM_OperatingSystem.SystemDrive}
  20.  
  21.     [PSCustomObject]@{
  22.         LocalComputerName = $env:COMPUTERNAME
  23.         Manufacturer = $CIM_ComputerSystem.Manufacturer
  24.         Model = $CIM_ComputerSystem.Model
  25.         SerialNumber = $CIM_BIOSElement.SerialNumber
  26.         CPU = $CIM_Processor.Name
  27.         SysDrive_Capacity_GB = '{0:N2}' -f ($CIM_LogicalDisk.Size / 1GB)
  28.         SysDrive_FreeSpace_GB ='{0:N2}' -f ($CIM_LogicalDisk.FreeSpace / 1GB)
  29.         SysDrive_FreeSpace_Pct = '{0:N0}' -f ($CIM_LogicalDisk.FreeSpace / $CIM_LogicalDisk.Size * 100)
  30.         RAM_GB = '{0:N2}' -f ($CIM_ComputerSystem.TotalPhysicalMemory / 1GB)
  31.         OperatingSystem_Name = $CIM_OperatingSystem.Caption
  32.         OperatingSystem_Version = $CIM_OperatingSystem.Version
  33.         OperatingSystem_BuildNumber = $CIM_OperatingSystem.BuildNumber
  34.         OperatingSystem_ServicePack = $CIM_OperatingSystem.ServicePackMajorVersion
  35.         CurrentUser = $CIM_ComputerSystem.UserName
  36.         LastBootUpTime = $CIM_OperatingSystem.LastBootUpTime
  37.         }
  38.  
  39.     }
  40.  
  41. $IC_Params = @{
  42.     ComputerName = $ComputerList
  43.     ScriptBlock = $IC_ScriptBlock
  44.     ErrorAction = 'SilentlyContinue'
  45.     }
  46. $RespondingSystems = Invoke-Command @IC_Params
  47. $NOT_RespondingSystems = $ComputerList.Where({
  48.     "[$_]" -notin $RespondingSystems.PSComputerName -and
  49.     $_ -notin $RespondingSystems.PSComputerName
  50.     })
  51.  
  52. $RespondingSystems
  53. $NOT_RespondingSystems
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement