Home > Uncategorized > Query SharePoint 2010 HTTPRequest Pages for JQuery References Utilizing PowerShell

Query SharePoint 2010 HTTPRequest Pages for JQuery References Utilizing PowerShell

I had a request from a customer who needed me to do a HTTP inline search query on a specific web application for all references of JQuery that was being utilized on all Site Collections and Sites within that Web Application.  Since the Web Application had over 1300 sites I needed to turn to PowerShell to iterate through all Sites, stream through the HTTPRequst pages and generate separate reports where JQuery references were found.

Below is how I accomplished this task using Powershell

————————————————————————————
Add-PSSnappin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue

$WebApp = Get-SPWebApplication(“URL OF WEB APPLICATION“)

$results = “PATH TO STORE HTTPRequest PAGE STREAMS
$JQueryResults = “PATH TO STORE JQUERY RESULTS FROM PAGE STREAMS

foreach ($site in $WebApp.Sites)
{
foreach ($web in $site.AllWebs)
{
[net.httpWebRequest] $request = [net.WebRequest]::create($web.Url)
$request.TimeOut = 600000
$request.UseDefaultCredentials = $true
[net.httpWebResponse] $response = $request.getResponse()
$responseURI = $response.ResponseURI
$responseAbsoluteURI = $responseURI.AbsoluteUri
$responseStream = $response.getResponseStream()
$streamReader = New-Object IO.StreamReader($responseStream)

$pathResults = $Results + “results_” + $web.Title + “.txt”
$result = $streamReader.ReadToEnd() >> $pathResults

$find = select-string -Path $pathResults -pattern “Jquery”
$jqueryPath = $JQueryResults + “jqueryresults_” + $web.Title + “.txt”
$web.Title >> $jqueryPath
$responseAbsoluteURI >> jqueryPath
“” >> $jqueryPath
$find  -replace [regex]::Escape($pathResults) >> $jqueryPath
}
}
————————————————————————————

 

 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: