Chapter 13
Activities
- We could write a fairly complicated cmdlet with
Invoke-CimMethod
, but that isn’t the best way to do it. Instead, we should use the cmdlet specifically written for this purpose,Stop- Process
, with theProcessId
of thenotepad
process:Stop-Process -Id 8480
- We can use
Invoke-CimMethod
like this:
Figure A.14 – Setting a default printer with CIM commands
In the first command, I put the printer object into a variable, then I used that variable as the input object for Invoke-CimMethod
and invoked the SetDefaultPrinter
method. The return value of 0
indicates success.
Note that the SetDefaultPrinter
method doesn’t appear on the $printer
variable. Unfortunately, we need to read the documentation to discover this method: