Powershell 开关参数

46次阅读
没有评论
Function Demo 
{
    Param(
    [Parameter(Mandatory=$false)]
    [Switch]$ColorText
    )
 
if($ColorText -eq $false)
    {
        Write-Host "Plain Text"
    }
elseif($ColorText -eq $true)
    {
        Write-Host "Color Text" -ForegroundColor Green
    }
 
}
正文完
 
评论(没有评论)