September 8th, 2014

PowerTip: Use Tab to Complete WMI Class Names

Doctor Scripto
Scripter

Summary: Use Tab completion to type WMI class names in Windows PowerShell.

Hey, Scripting Guy! Question I am using WMI in the Windows PowerShell console and in the Windows PowerShell ISE, and I am having a hard time
           correctly typing the long convoluted class names. How can I simplify the process and be more accurate?

Hey, Scripting Guy! AnswerUse the Get-CimInstance cmdlet instead of the Get-WmiObject cmdlet. One advantage (among many) of the 
           Get-CimInstance cmdlet is that it will do Tab completion on WMI class names.
           (The alias for Get-CimInstance cmdlet is GCIM.)

GCIM <tab> #
(cycles through the WMI classes in the default root\cimv2 WMI namespace)

GCIM Win32_P<tab> #
(cycles through WMI class names beginning with the letter P (such as, Win32_PageFile)

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.