I wrote about using the SharePoint web services from PowerShell before. In order to consume the web service, you needed wsdl.exe to generate a proxy class and csc.exe to generate an assembly. As Lee Holmes points out, those requirements make such PowerShell scripts not very portable because wsdl.exe is not part of the .NET Framework. Check out his blog post that describes how to consume a web service without those tools. Pretty ingenious to say the least!
If you want to use that function with SharePoint web services, you will need to provide some authentication. A quick solution is to add the following line:
$wc.Credentials=[System.Net.CredentialCache]::DefaultCredentials
behind the line that says:
$wc = new-object System.Net.WebClient
Of course, you can modify the function to provide authentication only if needed.

Post a Comment