Gather OS and HW Information

  • Get-Counter

  • Get-CimInstance

  • Get-WmiObject

  • Get-EventLog

Get-Counter

Gets performance counter data from local and remote computers.

Get-Counter
# Output1
Get-Counter -ListSet *memory*
# Output2
Get-Counter -ListSet *memory* | where CounterSetName -eq "Memory"
# Output3
Get-Counter -ListSet *memory* | where CounterSetName -eq "Memory" | select -Expand Paths
# Output4
Get-Counter "\Memory\% Committed Bytes In Use"
# Output5

Get-CimInstance

Gets the CIM instances of a class from a CIM server.

Get-CimInstance Win32_PhysicalMemory
# Output1
Get-CimClass -ClassName *disk*
# Output2
  • Below 2 commands have exactly same output when using Get-WmiObject

Get-CimInstance Win32_BIOS
# Output3
Get-CimInstance Win32_BIOS | select name,Version
# Output4
  • However, they expose different methods and properties

Get-CimInstance Win32_BIOS | Get-Member
# Output5

Get-WmiObject

Gets instances of WMI classes or information about the available classes.

Get-WmiObject -Class Win32_logicalDisk
# Output1
Get-WmiObject -Class Win32_diskpartition
# Output2
  • Below 2 commands have exactly same output when using Get-CimInstance

Get-WmiObject Win32_BIOS
# Output3
Get-WmiObject Win32_BIOS | select name,Version
# Output4
  • However, they expose different methods and properties

Get-WmiObject Win32_BIOS | Get-Member
# Output5

Get-EventLog

Gets the events in an event log, or a list of the event logs, on the local or remote computers.

Get-EventLog -LogName System -Newest 10 |format-table -Wrap -AutoSize
# Output1
Get-EventLog -LogName System -After "04/10/2018" -Before "04/11/2018" -EntryType Error
# Output2
Get-EventLog -LogName System -Source WinRM -EntryType Warning
# Output3
Get-EventLog -log System -Newest 1000 | where-object eventid -eq "1074" | format-table machinename, username, timegenerated -autosize
# Output4

Last updated