0

I have two versions of PnP PowerShell loaded on my machine:

SharePointPnPPowerShell2013   3.11.1907.0
SharePointPnPPowerShellOnline 3.1.1809.0

I'm having issues running code against SharePoint 2013. How do I specify which version of PnP PowerShell executes my code? I'm thinking the issue is I'm running the Online version rather than the 2013 version?

Thanks!

3 Answers 3

1

you can do below

Run them side by side Out of the box this won't work.

Well, you can install them, but PowerShell will automatically load the first one it finds. So in order to use them we will have to do some tweaking.

Make sure that you have uninstalled all instances of PnP Powershell that you currently have available on your machine. If you installed it previously using install-module, simply use uninstall-module -Name SharePointPnPPowerShell -AllVersions.

Now download all of the modules to a location that you are aware off, say you created a folder called c:\bin\pnppowershell

Use the following commands to download them:

Save-Module -Name SharePointPnPPowerShell2013 -Path c:\bin\pnppowershell
Save-Module -Name SharePointPnPPowerShell2016 -Path c:\bin\pnppowershell
Save-Module -Name SharePointPnPPowerShellOnline -Path c:\bin\pnppowershell

From now on, if you want to use a specific version of PnP PowerShell, you will have to manually import them (make sure to replace the version number with your current version):

import-module C:\bin\pnppowershell\SharePointPnPPowerShell2013\2.24.1803.0\sharepointpnppowershell2013.psd1 -DisableNameChecking

Answer directly copied from below link.

https://www.erwinmcm.com/running-the-various-versions-of-pnp-powershell-side-by-side/

1

I found a great post that resolves this: http://blogold.pixelmill.com/3718/running-multiple-versions-of-pnp-powershell/

To find out what version of Pnp PowerShell you are currently running:

Get-Module

To switch to another version:

Import-Module SharePointPnPPowerShell2013

or

Import-Module SharePointPnPPowerShellOnline
1

If you need to work with both versions of PnP PowerShell at the same time (maybe you are transferring content between SharePoint on-prem and Online) you can put the module name before the cmdlet to tell which module you want, like so:

SharePointPnPPowerShell2013\Connect-PnPOnline
SharePointPnPPowerShellOnline\Connect-PnPOnline

We did this and it works, but makes the code harder to read and you really have to concentrate to not mess things up. Forget the module name once and you are up for funny errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.