PowerShell Splatting the Argumentlist em Comando de Chamada
Como é possível usar os parâmetros coletados em uma tabela de hash para uso comArgumentList
emInvoke-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
O que quer que eu tente, está sempre reclamando da 'Fonte':
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
esteblogue fala sobre um problema semelhante, mas não consigo fazê-lo funcionar.
O mesmo vale para um simplesCopy-Item
dentroInvoke-Command
exemplo:
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
Obrigado pela ajuda.