I’m sitting in the PowerShell summit and just left the stage where I presented how the Odata extensions work and shared my new project (contributors welcome) to bring PowerShell-driven Odata endpoints to the masses
To make it clear just how easy it is to use, here is the code required to create a web service around get-process and stop-process.
$class = New-PshOdataClass Process -PK ID -Properties 'Name','ID' $class |Set-PshOdataMethod -verb get -cmdlet get-process -Params Name, ID -FilterParams Name $class |Set-PshOdataMethod -verb delete -cmdlet stop-process -FilterParams ID $class |New-PshOdataEndpoint
This will generate three files in a folder called odata that can be copied up to your IIS server. After an IISReset, the Process endpoint will be available via the following URLs:
- http://server/odata/Process
- http://server/odata/Process(‘3333′) # 3333 is the ID of the process you would like to retrieve. This is the only url that works for delete.
- http://server/odata/Process?name=notepad
- http://server/odata/Process?$filter=(name eq ‘notepad’)
- http://server/odata/Process?$format=application/json;odata=verbose #Used to render JSON instead of XML
I hope you enjoy, and please post issues on GitHub if you encounter any.
