January 22nd, 2016

PowerTip: Find single-name PowerShell functions

Doctor Scripto
Scripter

Summary: Learn how to find Windows PowerShell functions that do not have a hyphen in the name.

Hey, Scripting Guy! Question How can I easily find Windows PowerShell functions that do not have a hyphen in the name, but instead are single words, such as the Prompt function?

Hey, Scripting Guy! Answer Use the Get-Command cmdlet and return only functions. Filter out function names that do not contain a hyphen, for example:

gcm -CommandType function | where name -notmatch '-'

Note gcm is an alias for the Get-Command cmdlet.

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.

Feedback