samedi 20 octobre 2018

Implement Decorator Pattern in Powershell

I have my custom function f which runs some stuff then calls a predefined function Invoke-WebRequest

I want to make f accepts all the arguments that Invoke-WebRequest does, and pass those arguments to Invoke-WebRequst later.

 f --UseBasicParsing -Uri https://google.com -UseBasicParsing  -Body @{'name'='user'} -ErrorOnAction Stop
 # Some processing is made
 # then, the following is executed
 Invoke-WebRequest -Uri https://google.com -UseBasicParsing -Body @{'name'='user'} -ErrorOnAction Stop

Is there a fast way to achieve this? (Instead of declaring all the possible parameters in f)

Aucun commentaire:

Enregistrer un commentaire