PowerShell Die Argumentliste bei Invoke-Command splattern
Wie ist es möglich, die in einer Hash-Tabelle gesammelten Parameter für die Verwendung mit @ zu verwendeArgumentList
aufInvoke-Command
?
$CopyParams = @{
Source = 'E:\DEPARTMENTS\CBR\SHARE\Target'
Destination = 'E:\DEPARTMENTS\CBR\SHARE\Target 2'
Structure = 'yyyy-MM-dd'
}
Invoke-Command -Credential $Cred -ComputerName 'SERVER' -ScriptBlock ${Function:Copy-FilesHC} -ArgumentList @CopyParams
Was auch immer ich versuche, es beschwert sich immer über die 'Quelle':
Cannot validate argument on parameter 'Source'. The "Test-Path $_" validation script for the argument with
value "System.Collections.Hashtable" did not return true. Determine why the validation script failed
Dies blog spricht über ein ähnliches Problem, aber ich kann es nicht zum Laufen bringen.
Das gleiche gilt für ein einfachesCopy-Item
innerhalbInvoke-Command
, Beispiel:
Invoke-Command -Credential $Cred -ComputerName 'SERVER' -ScriptBlock {Copy-Item} -ArgumentList @CopyParams
Invoke-Command : Missing an argument for parameter 'ArgumentList'. Specify a parameter of type 'System.Obj
ect[]' and try again.
At line:11 char:89
+ ... ck {Copy-Item} -ArgumentList @CopyParams
Danke für deine Hilfe