jpsider / RestPS

Simple ReST Framework for Powershell
MIT License
113 stars 30 forks source link

Parse argument to Powershell script #55

Closed nicas4100 closed 3 years ago

nicas4100 commented 3 years ago

is it possible to parse a http parameter as an argument to the powershell script the api is executing?

jpsider commented 3 years ago

What do you mean by HTTP parameter?

nicas4100 commented 3 years ago

i have created an API that can execute a script to extend a user account, i want the api to take a argument and use that together with the powershell script

jpsider commented 3 years ago

so something like this:

http://fqdn/Endpoint?parameterName=paramValue

nicas4100 commented 3 years ago

yes exactly

nicas4100 commented 3 years ago

i just cant figure out how to make the route and how to direct it to the reqeustcommand

jpsider commented 3 years ago

yes! - take a look at the example here: https://github.com/jpsider/RestPS/blob/master/RestPS/endpoints/GET/Invoke-GetProcess.ps1

nicas4100 commented 3 years ago

thank you very much i will try it

very nice project btw

jpsider commented 3 years ago

Thanks! the example is a little rough around the edges, but should do what you need. if you have any issues, let me know.

nicas4100 commented 3 years ago

when i create the route what should i write in the RequestArgs field? "RequestType": "GET", "RequestURL": "/expand-user", "RequestCommand": "C:/Users/Administrator/Documents/expandExpireDate.ps1", "RequestArgs":

jpsider commented 3 years ago

You don't need to add anything. That line in the routes file, is just to provide data when you run the endpoint to display the available routes. But has no bearing on the function of the actual endpoint you are working on. (kinda a bad design on my part)

nicas4100 commented 3 years ago

okay thank you then it makes more sense

nicas4100 commented 3 years ago

I got it working thank you very much for your quick response

jpsider commented 3 years ago

fantastic!