PSCOVID-19

PSCOVID-19

Table of Contents

PSCOVID-19

I was bored and decided to create a hobby module which parses the CSV data that Johns Hopkins Center for Systems Science and of Engineering has been aggregating.

Why write it?…

  • I wanted to write something where I could grab the CSV data on Github and filter through it.
  • I’ve also really been digging using PowerShell classes lately (I was formerly an Add-Type on a C# file kind of dude).
  • I wanted to setup a CI/CD pipeline with Azure DevOps YAML builds that published the module to the PowerShell Gallery
  • I always love playing with ANSI escapes and SRG codes!
  • I guess it’s topical and kind of useful/fun?
  • I’m stuck at home and need to kill time folks!

Enter, PSCOVID-19!

The module only contains 2 functions. It is not my finest code, (already wish I didn’t have a dash in the name 😱), but I am sharing it in case anyone else wants to have fun with it.

Installing the module.

# Install the module
Install-Module -Name PSCOVID-19

Once installed there are two functions, Get-COVID19Data and Start-CVOID19Tracker.

Get-COVID19Data is the more “useful” function. It gets the data and returns it as a list of objects you can manipulate by grouping or filtering with Where-Object, Group-Object, Measure-Object, Select-Object, and Sort-Object etc…

# Gather the latest data
$covidData = Get-COVID19Data

# Filter the data to get all US cases and measure the total amount of confirmed cases across all of the data
$covidData | Where-Object {$_.CountryOrRegion -eq 'US'} | Measure-Object -Property Confirmed -Sum

# For you other New Englanders, Get all the New England states, sort by 'confirmed' cases and then format it out as a table
$covidData | Where-Object {$_.CountryOrRegion -eq 'US'} | Where-Object {
    $_.ProvinceOrState -eq 'Massachusetts' -or
    $_.ProvinceOrState -eq 'Rhode Island' -or
    $_.ProvinceOrState -eq 'Connecticut' -or
    $_.ProvinceOrState -eq 'New Hampshire' -or
    $_.ProvinceOrState -eq 'Vermont' -or
    $_.ProvinceOrState -eq 'Maine'
} | Sort-Object -Property Confirmed -Descending | Format-Table -AutoSize

# Get data for Italy
$covidData | Where-Object {$_.CountryOrRegion -eq 'Italy'}  | Format-Table -AutoSize

Here is a gif of it in action… get-covid19data

Start-COVID19Tracker is more of a fun function where I wanted to write something that felt like a console based monitoring app/dashboard.

# Start the tracker refreshing every 60 minutes for the US
Start-Covid19Tracker -CountryOrRegion US -UpdateInteraval 60

This is what you’ll see! start-covid19tracker

When I originally started writing the tracker I thought the data was being updated more often, it seems to get updated roughly once a day though.

The table is just outputting with Format-Table and because of this design choice has made sorting somewhat of a pain as I would need to build it into the function and just haven’t done so yet. Start-COVID19Tracker was still a fun little utility to make, I don’t think I’ve ever made one like this before in all my PowerShell travels.

That’s about it, it was fun to write. There are plenty of optimizations and design changes I may make or could make. Maybe you find it stupid, maybe you find it useful, but at least you found it 🤷.

Oh… one last thing! I had to make some awkward design choices to support both Windows PowerSell 5.1 and PowerShell 7. If everyone could move to PowerShell 7 that’d be great 😁! #PS7Now

Related links below…

Strange Times, A.K.A. My Complaining!

This post is/was a mix between personal and technical I guess. I am in my early 30’s and I cannot recall a time where things have seemed as strange as they are now with the global pandemic declared from COVID-19. Like many of you, I am really bummed out by global affairs, perhaps selfishly for some of the reasons below. As someone who has grown up and lived in the North East United States, the effects of COVID-19 for me kind of feels like a blizzard that never ends.

It feels like no matter who you are or where in the world you are, everyone has felt the effects in some way. Now to get my venting out of the way, these are the things really getting me down!…

PowerShell + DevOps Global Summit 2020 is Cancelled

This was a brutally hard decision, and a TON of thought from the DevOps Collective folks (who love and care about this community) went into this decision. As a volunteer for the DevOps Collective for OnRamp, a 2020 presenter, and someone who looks forward to this event more than any other each year, this is really tough news.

I do believe it is the right decision however. I know when the next Summit happens it will be great and will feel like this blip in 2020 never happened. So I still look forward to seeing ya’ll at the next Summit!!!

PowerShell + DevOps Global Summit Cancelled

Staying Inside at Home Really Sucks!

I might be the anomaly here, but I would consider myself an extrovert. I love going out and I love seeing my friends, family, and co-workers! Being stuck at home is really a drag for me. Coping with these changes even in the 5 days I have been has been challenging. I know I’ll make it through it, and staying in is the right thing to do. I can’t tell you how much I will appreciate the next time I have a chance to go out with my friends and co-workers to the local brewery after work and just have a beer and talk in person! Or even just stand up at my desk to talk to my team mates!

Luckily on this front everyone has been amazing at work at using their cameras, and for all you other folks in the same boat.. turn your cameras on!!! It makes online meetings feel so much more personal!

General Unease

I think like a lot of folks, this is a little unsettling in a sense that no one knows how long we’re in these new patterns. I know I have a good deal of essentials at home (food and boozeoh, and toilet paper), but I hope it starts to get better with all the measures our state/provincial and/or national governments are making with shutdowns and testing. I’m ready to get back to normal life ASAP!

Well, if you read this far thanks for reading my venting! Stay safe out there everyone!!!