这是我调用的一个函数.\GetEMSInstallers
。由于某些未知的原因,第一个参数总是失去它的价值:
function Get-EMSInstallers {
param (
$ems_for_amx_source = '\\server\ems_path',
$installers_dir = 'D:\installers'
)
process {
if (!(Test-Path "$installers_dir\EMS4AMX")) {
"Copying files and folders from $ems_for_amx_source to $installers_dir\EMS4AMX"
copy $ems_for_amx_source "$installers_dir\EMS4AMX" -rec -force
}
}
}
Get-EMSInstallers $args
当我调用它时,我得到这个输出:
Copying files and folders from to D:\installers\EMS4AMX
Copy-Item : Cannot bind argument to parameter 'Path' because it is an empty array.
At C:\Users\ad_ctjares\Desktop\Scripts\Ems\GetEMSInstallers.ps1:12 char:17
+ copy <<<< $ems_for_amx_source "$installers_dir\EMS4AMX" -rec -force
+ CategoryInfo : InvalidData: (:) [Copy-Item], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAllowed,Microsoft.PowerShell.Commands.CopyI
temCommand