Invoke-CimMethod is a PowerShell cmdlet that invokes a method on one or more CIM objects.
Invoke-CimMethod invokes a method attached to one or more CIM objects. Unlike a PowerShell cmdlet, an object method cannot receive piped objects directly; this generic cmdlet bridges that gap. section 15.2
Enable DHCP on matching adapters
Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter "description like '%intel%'" | Invoke-CimMethod -MethodName EnableDHCP
The method name needs no parentheses and is not case sensitive. section 15.2
Keep these constraints in mind:
Pass objects of only one CIM type, although multiple objects of that type are supported. section 15.2
Use -WhatIf and -Confirm for safer execution. section 15.2
Read ReturnValue to determine the operation result; 0 means success, while 84 means DHCP cannot be enabled on that adapter. section 15.2
How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it
How deep it goes
Explains discovery, invocation constraints, safety switches, and return values, but does not detail method implementation internals.
Examples
Uses Win32_NetworkAdapterConfiguration objects and the EnableDHCP method, including return values 0 and 84.
What it assumes
Assumes familiarity with pipelines and CIM instances while demonstrating method discovery from zero.
What you can do after
Operate/configure network adapters by discovering and invoking CIM methods, then interpreting their return values.
How it connects
Connects CIM objects with Get-CimClass, Get-CimInstance, WMI methods, and DHCP configuration.
CIM classuses · A CIM class is a Common Information Model schema definition describing a category of managed resources through properties, relationships, and operations.
Get-Commandused by · Get-Command is a PowerShell cmdlet that retrieves available commands, optionally matching names, verbs, nouns, or command types.
Select-Objectuses · Select-Object is a PowerShell cmdlet that selects properties or creates customized objects from input objects.
SQLhas part · SQL is a standardized declarative language for defining, querying, and manipulating data and structures in relational database systems.
This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.