This project is read-only.

PowerShell Cmdlets

Aug 21, 2014 at 7:54 PM

Is anyone here familiar with PowerShell scripting? I know that it's possible to make custom cmdlets that call managed code in .NET libraries. I think it would be really cool if we could provide a PowerShell API for GW2.NET.


I don't have any real PowerShell experience, so I can't write up an example. I just know what PowerShell is, and that we should make this happen.
Aug 23, 2014 at 9:30 AM
Edited Aug 23, 2014 at 2:31 PM
Turns out that PowerShell is already capable of retrieving and parsing JSON objects using the Invoke-RestMethod cmdlet.

It's nowhere near as flexible as a real GW2.NET-based implementation though.


Here's the same shell script as before, this time using GW2.NET and custom-written cmdlets.

Aug 24, 2014 at 3:08 PM
Alright, here's an advanced use case that shows where the power and flexibility of GW2.NET comes in.

Get-Items (Get-Items)[0..99] | Format-Table
-or- same as above, instead using named parameters
Get-Items -Id (Get-Items)[0..99] -Culture EN | Format-Table
From left to right: get item details for the first 100 discovered item identifiers, request the English version, and format the output as a table.

Aug 31, 2014 at 12:40 AM
So the user would be able to use GW2.NET from PS? Sweet.
Aug 31, 2014 at 9:05 AM
Pretty much. Nothing ever stopped people from using GW2.NET in PowerShell, but the code to do that looks awkward. What I want to do is write custom commands (cmdlets) that make the scripts look clean, as in the examples above.
Sep 2, 2014 at 9:30 AM
Just thought of a real-world example. You might want to monitor the build number for game updates. You don't want your main program to maintain an infinite loop for it, and writing a full windows service is also overkill. PowerShell is perfect for this scenario when combined with Windows Task Scheduler. You can then run other PowerShell commands when a game update is detected, or even transfer execution to your main program.
Sep 3, 2014 at 1:02 PM
Definetly sounds very useful