Use the function declared in this script to retrieve search results from SharePoint search via a dynamic web service proxy call to the SharePoint Search Web Service (search.asmx). The function utilizes PowerShell's New-WebServiceProxy cmdlet to dynamically create a web service client, and creates appropriate XML to submit the Search Query request.

function Query-SPSearch { 
        $Count = 10 
$QueryXml = @" 
<QueryPacket xmlns="urn:Microsoft.Search.Query" > 
            <QueryText type="STRING">$KeywordQuery</QueryText> 
    $ServicePath = "/_vti_bin/search.asmx" 
    $SearchWS = New-WebServiceProxy -Uri ($WebApplicationPath + $ServicePath-UseDefaultCredential 
    $Results = $SearchWS.QueryEx( $QueryXml ) 
    # we excluded all other result sets, but just in case get the one we want: