PowerShell salpicando la lista de argumentos en Invoke-Command
¿Cómo es posible usar los parámetros recopilados en una tabla hash para usar conArgumentList
enInvoke-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
Lo que sea que intente, siempre se queja de la 'Fuente':
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
EstaBlog habla de un problema similar, pero no puedo hacer que funcione.
Lo mismo es cierto para un simpleCopy-Item
dentroInvoke-Command
ejemplo:
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
Gracias por tu ayuda.