With the inaugural Microsoft Ignite conference fast approaching, I thought I’d tie together technology and the city in which it’s going to be held, given the news from the other day.
These three lines of PowerShell will get the crime data, and present it to the user in a PowerShell GridView.
The user will then be able to select a category (or categories), and view the individual crime details.
PowerShell really is a powerful tool for sysadmins. There are currently 34 PowerShell-related sessions scheduled at Ignite.
Regardless of the city’s reputation, I’m really looking forward to attending Ignite. I’m especially looking forward to the talks by Jeffrey Snover, inventor of PowerShell.
# Get the data, convert it to JSON | |
$jsonData = Invoke-WebRequest "https://data.cityofchicago.org/resource/ijzp-q8t2.json" | ConvertFrom-Json | |
# Filter our data set down to only the last month's crimes. Note that the data feed has a built-in lag of 7 days | |
$lastMonthsData = $jsonData | Where-Object {($_.date | get-date) -gt ((get-date).AddMonths(-1))} | |
# Show results, allowing user to select categories first and then view individual crimes | |
$lastMonthsData | Group-Object –Property primary_type | Sort-Object Count –Descending | Select-Object Name,Count,Group | Out-GridView –Title "Select a category (or multiple) to view details" –OutputMode Multiple | Select-Object –ExpandProperty Group | select primary_type,description,location_description,date,latitude,longitude,block,domestic,arrest,case_number | Sort-Object date –Descending | Out-GridView –Title "Crime Details" |