GOOGLE ADS

miércoles, 20 de abril de 2022

Pasar hashtable y args al comando de invocación de PowerShell como argumentos

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

Regla de Firestore para acceder a la generación de subcolección Permisos faltantes o insuficientes

Tengo problemas con las reglas de Firestore para permitir el acceso a algunos recursos en una subcolección. Tengo algunos requests document...