Advanced function

Advanced functions are those functions which can perform operations that are similar to the operations performed with the cmdlets. These functions are used when a user wants to write a function without having to write a compiled cmdlet.

The main difference between using a compiled cmdlet and an advanced function is that the compiled cmdlets are the classes of .NET Framework that must be written in a .NET framework language. And, the advanced functions are written in the PowerShell script language.

The following example describes how to use the advanced function in PowerShell:

PS C:\> function Send-Message  

>> {  

>>     [CmdletBinding()]  

>>     Param (  

>>         [ Parameter (Mandatory = $true)]  

>>         [string] $Name  

>>     )  

>>  

>>     Process  

>>     {  

>>         Write-Host ("Hi" + $Name + "!")  

>>     }  

>> }

Type the following command in the PowerShell console to get the output of above example:

PS C:\> Send-Message  

Output:

cmdlet Send-Greeting at command pipeline position 1
Supply values for the following parameters:
Name: Mudassir
Hi Mudassir!

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *