PowerShell: Basic Functions - Paiet/Tech-Journal-for-Everything GitHub Wiki
Basic Functions
- A function is a list of Windows PowerShell statements that
has a name that you assign
- A function includes the following items:
- A Function keyword
- A scope (optional)
- A name that you select
- Any number of named parameters (optional)
- One or more Windows PowerShell commands enclosed in braces
- Function format
function <function-name> {statements}
function Start-PSAdmin {Start-Process PowerShell -Verb RunAs}
- To add statements to the function, use one of the following
- Use a semi-colon to separate the statements
- Type each statement on a separate line