Keep your M365 PowerShell Modules up to date with M365PSProfile

Keep your M365 PowerShell Modules up to date with M365PSProfile

Hi All,

During the last few Weeks, i have been very busy with my Collegue Fabrice Reiser to build a PowerShell Module that keeps the PowerShell Modules (what we think ist needed) for a M365 Administrator up to date.

Our Goals where:

  • Simple One-Liner in the PowerShell Profile
  • No Admin Rights required -> Installation in the “CurrentUser” Scope
  • Fast and configurable -> Predefined Modules or can be defined by yourself
  • Support for PowerShell 5 and 7 (Install in CurrentUser Scope)
  • Parameter for Modules that should be installed and updated
  • Use the Microsoft.PowerShell.PSResourceGet (included in PowerShell 7.4)

I am using the new PSResourceGet here instead of the PowerShellGet commands.

Find-PSResource M365PSProfile
Install-PSResource M365PSProfile -Scope CurrentUser
Get-InstalledPSResource M365PSProfile -Scope CurrentUser

List all the Commands from the Module

Get-Command -Module M365PSProfile

If you have not already a PowerShell Profile you can do that by simply use the Add-M365PSProfile Command

Add-M365PSProfile
#View PowerShell Profile
more $profile

When not Modules with the Install-M365Module we will install the Standard M365 Modules (what we think is needed for M365 Administration).

You can display these Modules with the following command

Get-M365StandardModule

When you start PowerShell the next time, it will check and install the PowerShell Modules to the CurrentUser Scope

As the PowerShell Profile and Directory for the Modules in PowerShell 5.x and 7.x differ, you have to do the same thing again in PowerShell 7

Find-PSResource M365PSProfile
Install-PSResource M365PSProfile -Scope CurrentUser
Get-InstalledPSResource M365PSProfile -Scope CurrentUser

List all the Commands from the Module

Get-Command -Module M365PSProfile

If you have not already a PowerShell Profile you can do that by simply use the Add-M365PSProfile Command

Add-M365PSProfile
#View PowerShell Profile
more $profile

When not Modules with the Install-M365Module we will install the Standard M365 Modules (what we think is needed for M365 Administration).

You can display these Modules with the following command

Get-M365StandardModule

When you start PowerShell 7 the next time, it will check and install the PowerShell Modules to the CurrentUser Scope

This works also in Windows Terminal with PowerShell 5.1

And Windows Terminal with PowerShell 7.x

If you want to customize the Modules you can do that by editing the Profile

Notepad $Profile

#Add Custom Modules to the -Modules Array
Install-M365Module -Modules @("AZ","ExchangeOnlineManagement", "Icewolf.EXO.SpamAnalyze", "MicrosoftTeams", "Microsoft.Online.SharePoint.PowerShell", "PnP.PowerShell", "ORCA", "O365CentralizedAddInDeployment", "M365PSProfile", "MSCommerce", "WhiteboardAdmin", "Microsoft.Graph", "Microsoft.Graph.Beta", "MSIdentityTools", "PSMSALNet", "SEPPMail365", "SEPPmail365cloud")

And then it will check your Modules and keep them up to date

Note: You don’t need to use the Profile to check for Updates every time PowerShell starts. You can simply use the Command Install-M365Module at any time

Install-M365Module

Regards
Andres Bohren

M365 Logo

PowerShell Logo