面对PowerShell.exe参数

时间:2016-11-14 08:20:51

标签: powershell

我有一个PowerShell模块如下

function SkipCheck
{

 [CmdletBinding()]
    param
    (
        [boolean] $SkipCheck = $false
    )

    if (!($SkipCheck))
    {
        Write-Host "[WARNING]  Are you sure you want to contine" -ForegroundColor Yellow
        Pause
    }
    else
    {
        Write-Output "Skipping "
    }
}

我的脚本如下

[CmdletBinding(
)]

param(
[boolean] $SkipCheck= $false
)
Import-Module "C:\PowerShell\skipcheck.psm1"
Skipcheck

我正在按如下方式执行脚本,我收到警告消息,但我无法与之交互

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted -Command 'C:\PowerShell\testskip.ps1

enter image description here

当我通过在ISE中打开文件直接执行时,我会以不同的方式获取它,我可以进行交互

enter image description here

有人可以帮助我,参考链接http://www.zerrouki.com/powershell-exe-arguments/

0 个答案:

没有答案