In Part 1 of this series, we created a few files that are necessary to use the BlackBerry Web Services extensions. In Part 2, I showed you how to load them into PowerShell. Here in Part 3, we’ll be converting the C# sample code published by Research In Motion to PowerShell.
A note about SSL:
The BlackBerry Web Services rely on SSL communications so that the SOAP Requests & Responses are secure end-to-end. Most people use Self-Signed certificates for the BlackBerry Administration Service web pages, so there are only a few options. The most popular is to download the import the certificate into your trusted certificate authorities (I don’t care for this one). As a second option, you can just tell PowerShell to not worry about the invalid certificate. This second approach comes to us from the PowerShell Code Repository. (Link)
- Create an SSL Ignore policy for this script.
- Import the Type Definition from the BlackBerry Web Services.
- Define some variables that we’ll need for connecting.
- Create a metadata object that we’ll use for initialization & populate it.
- Create & populate a BWS and a BWSUtil Service connection.
- Get an authenticator object.
- Create an “encoded” BlackBerry login username.
- Connect to the service using the encoded username, password (from variable), and authenticator object.
- Create a user search request.
- Send the search request and get a response.
- Enumerate the response if successful.
The above pseudocode is a good framework and steps 1 – 7 can pretty much be repeated over and over for whatever you want to do within the BlackBerry Web Services. They can even be wrapped up into a nice little set of functions that you use whenever you need to connect.
Keep yourself tuned for Part 4 – Coding which will show each step of the pseudocode broken down into PowerShell. It should be online shortly!