I often need to be notified of a certain condition when a scheduled script executes.
With PowerShell V2, I can take advantage of our internal paging web service by using the New-WebServiceProxy cmdlet to take care of this notification.
Check out the help on this cmdlet to see a full list of capabilities. Help New-WebServiceProxy -Full
Before we dive into the actual call, lets interrogate the web service to see what it can do.
# Create a proxy for the Paging web service
$page = New-WebServiceProxy -Uri 'http://InternalPagingService/pageservice.asmx'
#List the methods
$page Get-Member -MemberType Method
You should see something like this:
The method we are going to use is RequestSinglePage.
Enter the following to see the expected parameters:
($page Get-Member -Name RequestSinglePage).definition
Looking at the end of the definition we see 2 parameters:
- string PagerId
- string NumericOrAlphaMessage
We now have all we need to page from script!
$page.RequestSinglePage('3141','Testing Page Web Service from PowerShell')
If you need confirmation of the Web Service call, you can look at the FunctionStatus property of the executed Web Service.
($page.RequestSinglePage('3141','Test Page from PowerShell')).FunctionStatus
This returns - SUCCESS
Wrapping this web service call around some return code if fairly straight forward and is left as an exercise for the reader.
If you don't have an internal Web Service handy, try out http://www.webservicex.net/WeatherForecast.asmx