我是PowerShell的新手,无法理解为什么会出现以下错误
Invoke-Command:找不到接受参数的位置参数 ' d:\部署\ file.zip&#39 ;. 在D:\ source \ Scripts \ Build-Deploy \ Build-Deploy \ ServersDeploy.ps1:105 char:5
这是正在运行的脚本
params([string[[]]$servers, [string]$dest_package_path, [string]$src_package_path,[string]$deploy_script)
Invoke-Command -ComputerName $servers -ScriptBlock {
param($dest_package_path,$src_package_path,$deploy_script)
Write-Output "Destination path = $dest_package_path"
Write-Output "Copying zip $src_package_path to the destination host"
New-Item -ItemType Directory -Force -Path $dest_package_path
Write-Output "Directory Created"
Copy-Item -Path $src_package_path -Destination $dest_package_path -Force
Write-Host "Copying remote deploy scripts to the destination host"
Copy-Item -Path $deploy_script -Destination $dest_package_path -Force
} -ArgumentList $dest_package_path $src_package_path $deploy_script
答案 0 :(得分:4)
因为您使用空格而不是逗号分隔参数。这使他们成为a := (a dependsOn b).value
的新论据。
Invoke-Command
一个带数组的参数:
-ArgumentList