This blog has moved to http://ThePowerShellGuy.com
Greetings /\/\o\/\/
This is the first part of a series about using MSN Search Web Service from MSH.
Before we can start to use the MSN Search Web Service API from MSH we need to do a couple of things first :
The first step is to
Get an AppID (in
Developer Help)
You need use this AppID later in the script, as you connect to the Web API
You need to sign in to the Passport Network, and give an Applicationname to get this ID.
For more info see
MSN Search section of the MSN Developer CenterThen we need to "Import" the MSNSearch Web Reference.
this involves 3 steps :
to do this we First use wsdl.exe (Microsoft Web Services Description Language Utility) from VS2005 or the SDK.
MSH>& 'C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\wsdl.exe' http://soap.search.msn.com/webservices.asmx?wsdl
Microsoft (R) Web Services Description Language Utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\MSNSearchService.cs'.
This generates a C# file that we compile in step 2 :
MSH>$compiler = "$env:windir/Microsoft.NET/Framework/v2.0.50727/csc"
MSH>&$compiler /target:library MSNSearchService.cs
Now we got a DLL that we can load in MSH :
MSH>[System.Reflection.Assembly]::LoadFile("g:\mowsh\MSNSearchService.dll")
GAC Version Location
--- ------- --------
False v2.0.50727 g:\mowsh\MSNSearchService.dll
Now we are Ready to make use of the Web Service just like we use .NET objects.
we just declare them with New-Object and start using them.
[System.Reflection.Assembly]::LoadFile("g:\mowsh\MSNSearchService.dll")
# Declare MSH Seach Service Object
$MSN = new-object MSNSearchService
# Declare a source request
$s = new-object SourceRequest
$s.source = [sourcetype]::web
$s.ResultFields = ([ResultFieldMask]::All
# Declare a Search request (You need to Provide your AppID here !!)
$sr = new-object SearchRequest
$sr.AppID = "YOUR appID HERE !!!!!!!!"
$sr.Requests = $S
$sr.Flags = [SearchFlags]::None
$sr.CultureInfo = "en-US"
# Set the Query
$sr.query = "win32_QuotaEvent"
# Do the Search
$r = new-object sourceResponse
$r = $MSN.Search($sr)
# output results
$r.responses[0].results | select Title,Description,Url | fl
Title : /\/\o\/\/ on MSH (Monad)
Description : win32_quotaevent I used Get-WmiClasses from Wmi-Help Part 1 , to list them (we installed nothing more on the R2 server as FSR
M) (its easy to use this script remote by filling in the Path in the ...
Url : http://mow001.blogspot.com/
Title : /\/\o\/\/ on MSH (Monad): Watching FSRM Quota and filescreen events ...
Description : win32_quotaevent I used Get-WmiClasses from Wmi-Help Part 1 , to list them (we installed nothing more on the R2 server as FSR
M) (its easy to use this script remote by filling in the Path in the ...
Url : http://mow001.blogspot.com/2006/01/watching-fsrm-quota-and-filescreen.html
From here on you can just change the Query, and search again.
$sr.query = "mow"
$r = $MSN.Search($sr)
$r.responses[0].results
etc.
I think it is very cool, it take a while to set it up, but then it's very easy and powerfull to use MSN search from MSH like this,
In the next part, more about "Paged" results and Making the Links Usefull,
and I will make it more a script.
enjoy your searches,
gr /\/\o\/\/
Tags : Monad msh