Normalmente uno puede hacer lo siguiente:
function example{
param(
$Parameter1,
$Parameter2
)
"Parameter1: $Parameter1"
"Parameter2: $Parameter2"
$PSBoundParameters
$args
}
y pasar parámetros explícitamente o salpicando así:
$options = @{parameter1='bounded parameter'}
example @options -Parameter2 'will be bounded too' 'this will go into args' -Parameter3 'this will too','and this one also'
Parameter1: bounded parameter
Parameter2: will be bounded too
Key Value
--- -----
Parameter1 bounded parameters
Parameter2 will be bounded too
this will go into args
-Parameter3
this will too
and this one also
Me gustaría replicar el comportamiento de esa sintaxis de alguna manera cuando uso el comando de invocación. Idealmente algo como esta sintaxis:
$options = @{parameter1='bounded parameter';parameter3='this will too'}
Invoke-Command -Computername REMOTESERVER -ArgumentList @options 'will be bounded to parameter2' 'this will go into args', 'and this one also' -ScriptBlock {'block'}
He visto esta respuesta:
https://stackoverflow.com/a/36283506/12603110 que sugiere envolver el bloque de script con
No hay comentarios:
Publicar un comentario