WMI CIM

WMI is the implementation of the Web-Based Enterprise Management (WBEM) and Common Information Model (CIM) standards from the Distributed Management Task Force (DMTF). It allows you to manage and administrate clients and servers, locally and remotely. It is important that you learn how WMI/CIM works technically, and we therefore recommend you read about its basics, for example, in the Windows internals books: https://docs.microsoft.com/en-us/sysinternals/learn/windows-internals.

These were the old cmdlets in early PowerShell:

  • Get-WmiObject
  • Invoke-WmiMethod
  • Remove-WmiObject
  • Register-WmiEvent
  • Set-WmiInstance

The v2/CIM cmdlets replaced the so-called WMI v1 cmdlets, which are completely missing in PowerShell Core 6.

Further information can be found here: https://blogs.msdn.microsoft.com/powershell/2012/08/24/introduction-to-cim-cmdlets/.

Some typical examples for the CIM usage are as follows:

#Showing all the cmdlets
Get-Command -Noun CIM*

<#

CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-CimAssociatedInstance 1.0.0.0 CimCmdlets
Cmdlet Get-CimClass 1.0.0.0 CimCmdlets
Cmdlet Get-CimInstance 1.0.0.0 CimCmdlets
Cmdlet Get-CimSession 1.0.0.0 CimCmdlets
Cmdlet Invoke-CimMethod 1.0.0.0 CimCmdlets
Cmdlet New-CimInstance 1.0.0.0 CimCmdlets
Cmdlet New-CimSession 1.0.0.0 CimCmdlets
Cmdlet New-CimSessionOption 1.0.0.0 CimCmdlets
Cmdlet Register-CimIndicationEvent 1.0.0.0 CimCmdlets
Cmdlet Remove-CimInstance 1.0.0.0 CimCmdlets
Cmdlet Remove-CimSession 1.0.0.0 CimCmdlets
Cmdlet Set-CimInstance 1.0.0.0 CimCmdlets
#>

#Instance for OS
$inst = Get-CimInstance Win32_OperatingSystem

#Working with service
Get-CimInstance -ClassName win32_service -Property name, state -Fil "name = 'bits'"

#Finding Cim class
Get-CimClass -ClassName *process* -MethodName term*

#Working with session
$logon = Get-CimInstance win32_logonsession
Get-CimAssociatedInstance $logon[0] -ResultClassName win32_useraccount

#Working with harddrive
$disk = Get-CimInstance win32_logicaldisk
Get-CimAssociatedInstance $disk[0] | Get-Member | Select-Object typename -Unique
Get-CimAssociatedInstance $disk[0] -ResultClassName win32_directory

#View associations from the logonsession and its instances

Get-CimInstance win32_logonsession | Get-CimAssociatedInstance
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.119.17