Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

MSDN content from PowerShell using WDSL

When I saw this post : MSDN content is also available as a Web service 

Of course I had to try this in PowerShell

The following code I came up with while testing will get the title of the following post http://msdn.microsoft.com/en-us/library/aa973757(VS.85).aspx :

 

$msdn = New-WebServiceProxy http://services.msdn.microsoft.com/ContentServices/ContentService.asmx?wsdl
$cr = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vices_ContentService_asmx_wsdl.getContentRequest
$cr.contentIdentifier = 'aa973757'
$rd = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vices_ContentService_asmx_wsdl.requestedDocument
$rd.selector = 'Mtps.Xhtml'
$cr.requestedDocuments  = $rd
$cr.locale = 'de-de'
$msdn.GetContent($cr).primaryDocuments[0].any.div.div[0].'#text'
$cr.locale = 'en-US'
$msdn.GetContent($cr).primaryDocuments[0].any.div.div[0].'#text'

The Output looks like this :

PS > $cr.locale = 'de-de'
PS > $msdn.GetContent($cr).primaryDocuments[0].any.div.div[0].'#text'
Erste Schritte mit Windows PowerShell
PS > $cr.locale = 'en-US'
PS > $msdn.GetContent($cr).primaryDocuments[0].any.div.div[0].'#text'
Windows PowerShell Getting Started Guide

This if of course only a proof of concept, but would be cool to add online help this way to PowerShell or PowerTab (an excelent help with using Webservices, update-TabexpansionType after loading the webservice and you can tabcomplete the autogenerated types look here http://powertab.codeplex.com/ for the latest version for PowerShell V 2.0 )

try for example this :

$cr.contentIdentifier = 'aa394435'
$msdn.GetContent($cr).primaryDocuments[0].any | fc
$msdn.GetContent($cr).primaryDocuments[0].any.div[2].p

Enjoy, 

Greetings MOW

* Update * Of course I was not the only one with this idea, a much advanced example you can find here : http://poshcode.org/1724

Published Monday, July 26, 2010 5:55 PM by MoW
Filed under: ,

Comments

Anonymous comments are disabled