Using PowerShell to get data for Microsoft Ignite

I was registered for Ignite yesterday (yipeeee!!), and decided to take a look at the session list. 

Navigation and search is a bit of a chore, so I set out to see if I could get the information I needed via PowerShell. If so, I was free to obtain whatever data wanted quickly.

Here’s what i came up with. After the script a couple of examples of post querying the data are given. Note that instead of querying the web services each time for data, I’ve just downloaded all the data, and query it locally. This isn’t really best practice, but (IMO) the low size of the dataset mitigates this to some extent.

Recommendations for improving or additions are more than welcome. 🙂 It will be posted to GitHub shortly.

#define variables

$web = @{
contentType = 'application/json;charset=UTF-8'
userAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
baseURL = ''
searchURL = 'session/anon/search'


$searchbody = '{"searchText":"*","sortOption":"None","searchFacets":{"facets":[],"personalizationFacets":[]}}'

#invoke web request actions
$request = Invoke-WebRequest -Uri '' -Method Get -ContentType $web.contentType -UserAgent $web.userAgent -SessionVariable session
$searchResults = Invoke-WebRequest -Uri "$($web.baseURL)/$($web.searchURL)" -Body $searchbody -Method Post -ContentType $web.contentType -UserAgent $web.userAgent -WebSession $session

#Convert returned data from JSON
$sessiondata = ConvertFrom-Json -InputObject $searchResults

#Obtain count of the number of sessions
[int32] $sessionCount = $

#Because we need to use a reference variable in the DivRem method, it needs to be declared first.
[int32] $remainder = 0

<#Only ten results are displayed at a time, so we need to get the total count of sessions, and divide by ten. 
If the result is not an integer, we add 1 to the value and convert to integer#>

$PageCount = [System.Math]::DivRem($sessionCount,10,[ref]$remainder)
If ($remainder -gt 0) 
$PageCount ++

#Now parse through each page, converting to JSON. Once converted, add the result data to the data array
For ($page = 1;$page -le $PageCount;$page++) 
$searchbody = "{`"searchText`":`"*`",`"searchPage`":$($page),`"sortOption`":`"None`",`"searchFacets`":{`"facets`":[],`"personalizationFacets`":[]}}"
$searchResults = Invoke-WebRequest -Uri "$($web.baseURL)/$($web.searchURL)" -Body $searchbody -Method Post -ContentType $web.contentType -UserAgent $web.userAgent -WebSession $session
$sessiondata = ConvertFrom-Json -InputObject $searchResults
[array] $data += $
Write-Output -InputObject "Processed page $page of $PageCount"


#Get all sessions with Jeffrey Snover 
$data | Where-Object -FilterScript { 'Jeffrey Snover' -in $_.speakerNames }


#Return all speakers
$data | Select-Object -ExpandProperty SpeakerNames -Unique| Sort-Object