Skip to content

Instantly share code, notes, and snippets.

View sstorie's full-sized avatar

Sam Storie sstorie

  • SPS Commerce
  • Minnesota, USA
  • X @sstorie
View GitHub Profile
@sstorie
sstorie / WMI-CIM-CodeExamples.ps1
Created December 6, 2021 18:28 — forked from ScriptAutomate/WMI-CIM-CodeExamples.ps1
Examples of Using WMI/CIM Cmdlets
break #To prevent accidental execution of all commands
# WMI cmdlets: Work against anything, where DCOM RPC dynamic port range is available
# CIM cmdlets: Exist in PowerShell v3 and up, can use DCOM or WSMAN. Can have CimSessions. Microsoft going forward.
$Creds = Get-Credential
Get-WmiObject -Class win32_computersystem
Get-WmiObject -Class win32_computersystem -ComputerName server1 -Credential $Creds
Get-CimInstance -Class win32_computersystem -ComputerName server1 -Credential $Creds
$Session = New-CimSession -ComputerName server1 -Credential $Creds
Get-CimInstance -Class win32_computersystem -CimSession $Session
Get-CimSession