Ying Li at myITforum.com

PowerShell & System Center

Powershell command categories

As you may already know, there are four categories of commands in PowerShell: cmdlets, functions, scripts, and native Win32 executables.

Cmdlets is a term that’s specific to PowerShell environment. A comlet is implemented by a .NET class and building cmdlets is a developer task and requires the PowerShell SDK.

get-wmiobject

Cmdlets always follows Verb-Noun pattern, where the verb specifies the action and the noun specifies the object to operate on.

The next type of command is function. This is a named piece of PowerShell script code that lives in memory while the interpreter is running, and is discarded on exit.

Functions are made up of user-defined code that is passed once when defined. This parsed representation is preserved so it doesn’t have to be re-parsed every time it is used.

A script command is a piece of PowerShell code that lives in a file with a .ps1 extension. In version 1.0 of PowerShell, these script files are loaded and parsed every time they are run, making them somewhat slower than functions to start (although once started, they run at the same speed).

The last type of command is called a native command. These are external programs (typically executables) that can be executed by the operating system. Native commands are the slowest of the command types.

Posted: Mar 29 2007, 09:15 AM by yli628 | with no comments
Filed under:

Comments

No Comments