Mur*_*dvi 4 powershell batch-file parameter-passing
我有一个批处理文件,它将调用Powershell脚本:
批处理文件: @ECHO OFF powershell ..\PowerShellScript.ps1
powershell脚本又有一个需要参数的函数:
POWERSHELL SCRIPT:
function PSFunction([string]$Parameter1)
{
Write-Host $Parameter1
}
Run Code Online (Sandbox Code Playgroud)
假设我有一个值:VALUE1需要在调用PowerShellScript.ps1时从批处理文件传递,如何将其传递给函数PSFunction以使我的输出为VALUE1?
将脚本修改为如下所示
function PSFunction([string]$Parameter1)
{
Write-Host $Parameter1
}
PSFunction $args[0]
Run Code Online (Sandbox Code Playgroud)
从批处理文件中,它看起来像
powershell ..\PowerShellScript.ps1 VALUE1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9560 次 |
| 最近记录: |