Running multiple versions of PnP-PowerShell

This is by no means new news, as Chris Kent and Erwin van Hunen have already covered how to do this, but I wanted to add my personal notes as someone who already had unintentionally installed multiple versions of PowerShell, through both the .msi install files and the PowerShell gallery because I’m apparently an overachiever.
First, figure out what you have installed:
Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending
This will list out all the versions of PnP that you have currently have installed. If you have installed multiple versions in the past, you may have multiple versions of even the 2016 or 2013 or Online installed. (My screenshot below looks really clean – I forgot to take a screenshot before, but I had five versions installed before!)

If you have multiple, conflicting versions installed, then run this code below. (If you just have one, then skip down to the next section.) Specify the flavor of PnP-Powershell and the version number to replace the one I’m showing below:
Get-InstalledModule -Name "SharePointPnPPowerShellOnline" -RequiredVersion 3.2.1810.0 | Uninstall-Module
Repeat this as many times as you need to.
Next, install the versions of PnP-PowerShell that you want:
Chris’ article provides a couple options for getting your desired setup. The breakdown is that you can install all three via the Powershell Gallery, which will run 2013 by default. Or, you can just install Online via the Powershell Gallery, save the other two .msi files from the Releases page, and load those manually as needed. Those methods work great if you are starting from scratch, but if you have already installed with .msi files, then you will need the additional step of removing the environment variables. Here’s what I did, step by step, to install with Chris’ first method.

    1. Be sure you’re running Powershell as an administrator.
    2. You might find it easier just to uninstall ALL versions of Powershell, using the above approach.
    3. Open Control Panel > System Properties > Advanced tab and click Environment Variables.
    4. Look for the PSMODULEPATH variable, click it to select it, and delete it.
    5. At this point, you can follow Chris’ instructions to install with your desired method. I used the first method, so I installed all three flavors of PnP-PowerShell with these commands:
      Install-Module SharePointPnPPowerShell2013
      Install-Module SharePointPnPPowerShell2016 -AllowClobber
      Install-Module SharePointPnPPowerShellOnline -AllowClobber
      (The -AllowClobber parameter allows multiple versions to be installed.)
    6. At this point, I can run from 2013 by default, or choose which flavor I want to use when I first start my Powershell session, by using the commands:
      Import-Module SharePointPnPPowerShell2016
      or
      Import-Module SharePointPnPPowerShellOnline
      (You’ll see a warning message, which means it’s loaded just fine!)

One more tip, which I found helpful — you can always run Get-Module and see which module you’re running:



Corrie Haffly
Senior Web Developer
Sea Otter Enthusiast
Your SharePoint Tour Guide

Leave a Comment

Your email address will not be published. Required fields are marked *

Enter Code *

Filed Under

Related

Let's meet the final panelist for the #PixelMillWebinars: President/Co-Founder of PixelMill, Author, and Microsoft RD + MVP @EricOverfield!

Read more about Eric & join us next week for "The State of the Microsoft Empowered Digital Workspace"

http://ow.ly/4CQ950DfU6b

2

Let's meet the next panelist for the #PixelMillWebinars: #Microsoft GTM director at @AvePoint, Author, and Microsoft RD + MVP @buckleyplanet!

Read more about Christian & join us next week for "The State of the Microsoft Empowered Digital Workspace"

http://ow.ly/6V9u50DeNu8

2

This Friday, the amazing #M365California team presents a free community-focused event dedicated to educate and engage members of the local technical community. Check out the list of top notch speakers & their equally amazing sessions and join the party! http://ow.ly/W2cw50DdMem

Let's meet the next of our panelists for next week's episode of the #PixelMillWebinars: Author, Consultant, and #MicrosoftMVP, @susanhanley!

Read more about Susan & join us next week for "The State of the Microsoft Empowered Digital Workspace"

http://ow.ly/cCek50DdKZb

2

Let's meet the first of our panelists for next week's episode of the #PixelMillWebinars: Author, CEO of @visualsp and #MicrosoftMVP, @asifrehmani!

Read more about Asif & join us next week for "The State of the Microsoft Empowered Digital Workspace"

http://ow.ly/wrmd50DcJYr

2

Subscribe to PixelMill's
E-news

* indicates required

Let's Talk Digital
Workspaces Today

Get In Touch