下面我有PS腳本如何傳遞參數的功能PowerShell的
Function Publish
{
Param(
[parameter(Mandatory=$true)]
[String]
$RELEASEDIR,
[parameter(Mandatory=$true)]
[String]
$SERVICENAME,
[parameter(Mandatory=$true)]
[String]
$SERVER
)
Get-ChildItem "$RELEASEDIR\*"
$service = Get-Service -Name $SERVICENAME -Computername $SERVER -ErrorAction SilentlyContinue
$service.Status
}
Publish
如何我甚至在執行傳遞參數後,執行該
PS C:\Release\RPCPS> .\RPCPublish.ps1 -RELEASEDIR "C:\Location" -SERVICENAME "value" -SERVER "server"
cmdlet Publish at command pipeline position 1
Supply values for the following parameters:
RELEASEDIR:
,劇本又懷孕。我在這裏做錯了事。 請幫我
。\ RPCPublish.ps1 =/=你的函數'publish' – Matt
聽不懂 – Kally
[dotsource(https://ss64.com/ps/source.html)腳本,做'發佈-arg1 -arg2 -arg3',並且考慮將函數名改爲動詞 - 名詞格式 – 4c74356b41