Thursday, September 25, 2008

Calling Web Services through PowerShell

I do believe that in V2, this will be something that can be done natively within PowerShell. In the meantime, there are a few well documented ways to do this, check out Lee Holmes' example.

I have approached this from a slightly different angle. If you have access to Visual Studio, try something like this:

  1. Create a console app
  2. Set a web reference to your predefined web service
  3. Create your method
  4. Compile
  5. Move the exe to the appropriate location and call as needed from PowerShell

A specific example: I have a paging web service that I can call from my automated monitoring PowerShell scripts when certain conditions are met.

If ($cnt -gt 500) { D:\Script:\Paging.exe "9773" "Import Count: $cnt" }

Works like a charm!

No comments: