Countdown to Ignite: View Chicago’s Crime Data with PowerShell

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.

2015-04-23 14_42_02

The user will then be able to select a category (or categories), and view the individual crime details.

2015-04-23 14_42_52

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 "" | 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 {($ | 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"

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s