Book Image

PowerShell Troubleshooting Guide

By : Mike Shepard
Book Image

PowerShell Troubleshooting Guide

By: Mike Shepard

Overview of this book

Table of Contents (15 chapters)
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Functions


Functions are similar to cmdlets and should follow the same naming conventions. Whereas cmdlets are compiled units of PowerShell functionality written in managed code like C#, functions are written using the PowerShell language. Starting with PowerShell 2.0, it has been possible to write advanced functions, which are very similar to cmdlets. It is possible to use common parameters and risk mitigation parameters with advanced functions. An example of a function is shown as follows:

function get-PowerShellVersionMessage{
param($name)
    $PowerShellVersion=$PSVersionTable.PSVersion
    return "We're using $PowerShellVersion, $name!"
}

Calling the function at the command line is straightforward, as shown in the following screenshot: