PowerShell Prep

Whenever I switch to a new computer, I frequently launch PowerShell, run a cmdlet, and the screen barfs red text to let me know that the cmdlet isn’t recognized. Which quickly reminds me that I’m an idiot and forgot to install the modules to my new system. Enter this blog post!

While I often keep PowerShell notes/tips in my OneNote notebook, I thought it would be useful for others to share here. There are many great blog posts already about setting up PowerShell, but I don’t recall seeing one that includes all of the “gotchas” that come with setting up a new system. Hopefully I’ve caught them here.

If you’re on a Windows machine, you should already have some basic modules, but how do you know for sure? Launch PowerShell (always run as administrator) and type:

Get-Module -ListAvailable

You should see a “laundry list” of the available PowerShell modules, which at this point, are primarily the ones installed by default with PowerShell. So with all these modules, why do you need anymore? There are thousands of different PowerShell modules out there that serve different purposes. For example, the ones I use regularly are MSOnline, ExchangeOnlineManagement, MicrosoftTeams and AzureADPreview for Microsoft 365 (M365) administration.

So how do you get these modules? First, it’s good to know where they come from, which is usually the PowerShell Gallery. The easiest way to install a new module is through PowerShell itself. Microsoft has some documentation on Getting Started with the PowerShell Gallery, but skipping to the good part – here’s the info on how to install a module:

Install-Module installs the module to $env:ProgramFiles\WindowsPowerShell\Modules by default. This requires an administrator account.”

The catch: before you can use Install-Module to install modules from the PowerShell Gallery, you must first install the PowerShellGet module. Another catch: you need to install the NuGet Provider before you can get PowerShellGet (get it?). Remember to run your PowerShell session as an administrator:

Install-PackageProvider -Name NuGet -Force
Install-Module -Name PowerShellGet -Force

And one more catch: if Install-PackageProvider throws an error, it may mean that your system is not running the latest version of TLS, which will need to be installed. Ali Tajran has a great post on how to resolve this issue, so please see his post if you need to check/update TLS.

FINALLY your system is ready to install some modules! Search the PowerShell Gallery to find the modules that you need to wield the power of PowerShell!

Hey PowerShell – you’re pretty…

As a Microsoft 365 admin, I use PowerShell frequently. Like, every. single. day. My fellow Exchange Online admins will often ask where to find something in the Exchange Admin Center (EAC), and my response is usually the profound, “I dunno.” Finally, one of them asked how I can be an M365 global admin, and not know where stuff is? For that question, I had a much better answer – “Because I rarely use the GUI – I use PowerShell!”

That conversation prompted a request from my colleagues to get them started with PowerShell – what it is, how it works, how can they use it effectively, etc. Enter digitaldivas.net – my long-languishing blog that I have vowed to start using more, primarily for PowerShell posts. For a while now I have wanted a place for “notes to myself” on things that worked, things that didn’t, things I want to remember for later, so my goal is to do that here in the hopes that it will help others as well. Stay tuned!