如果使用-command参数,则意味着您将在后面的引号之间编写原始PowerShell代码(允许您像调用脚本一样调用脚本)。
PowerShell -Command "Get-Date; pause;"
要调用PowerShell脚本文件,应使用:
PowerShell -File "Your-Script.ps1 -Parameter1 Argument1 -Parameter2 Argument2"
https://docs.microsoft.com/en-us/powershell/scripting/components/console/powershell.exe-command-line-help?view=powershell-6
我将编写一个PowerShell脚本,它接受您的根路径和releaseType作为参数,并执行该脚本。
Param($rootPath,$releaseType)
{
robocopy "$($rootPath)\$($releaseType)\siteLoad" "$($rootPath)\$($releaseType)\site"
}
我从来没有用过詹金斯,所以我希望它能像我期望的那样工作!
sexec myuser@mysite.com -pw=mypassword -cmd=""PowerShell -File 'C:\batch\newScript.ps1' -RootPath 'c:\inetpub\mysite' -ReleaseType {ReleaseType}""