官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 民县| 广德县| 赣州市| 驻马店市| 汉川市| 锦屏县| 望江县| 潜江市| 宜章县| 甘南县| 扎赉特旗| 寿光市| 汨罗市| 喀喇| 乌苏市| 镇巴县| 临猗县| 同心县| 柳江县| 皮山县| 灵山县| 桑植县| 桦南县| 峨山| 项城市| 大石桥市| 托克逊县| 甘德县| 观塘区| 桃园市| 平安县| 赣州市| 丹江口市| 陇川县| 道孚县| 江陵县| 图木舒克市| 开封县| 鹤壁市| 新化县| 四平市|