/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" about_Switch Documentation "," Switch -regEx "," Dir, Dir and more Dir in MSH "," Simple Show-Image function for Monad "," MSH out-zip Function "," get a Users LastLogontime and Domaincontroller fro... "," Some fun With Monads Add-Member, MP3 files and COM "," MSH snap-in to Translate IADsLargeInteger to Int64 "," Commandline editing with MSH. "," MSH Scroll-host function "," ")

Wednesday, February 01, 2006

 


Search with MSNSearch Web API from MSH (Part 1)



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 Center

Then 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 :


Comments:
Anonymous Anonymous
be sure to edit the CSharp file and add a namespace, otherwise types surfaced by the this assembly will make it difficult to get to the types in the SYSTEM namespace. Either that, or use the /n: flag for WSDL.EXE
 
Post a Comment



<< Home

Archives

October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?