pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
988 stars 662 forks source link

Ambiguous instructions on trying to get started #2074

Open smchargue opened 5 years ago

smchargue commented 5 years ago

I'm trying to write powershell code that works for SP Online and SP 2016; the instructions below are vague and ambiguous on how to set that environment up. I ran the install for PnPPowerShellOnline; my scripts worked, but fail (anything dealing with the Taxonomy) when trying to run the same scripts against SP2016. Do i need to uninstall PnPPowerShellOnline and install PnPPowerShell2016 ?

SharePoint Version Command to install
SharePoint Online Install-Module SharePointPnPPowerShellOnline
SharePoint 2019 Install-Module SharePointPnPPowerShell2019
SharePoint 2016 Install-Module SharePointPnPPowerShell2016
SharePoint 2013 Install-Module SharePointPnPPowerShell2013
ghost commented 5 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

KoenZomers commented 5 years ago

You always must use the PnP PowerShell version which corresponds with the platform you are targeting. If you want to target multiple versions from one machine, that can be done, but requires explicit module loading manually. Just use Install-Module on all of the versions you want to use. Then in a new PowerShell window where you haven't executed or even typed in any PnP commands yet, use:

import-module SharePointPnPPowerShellOnline

Replace Online with 2019/2016/2013 depending on which platform you target. This way you explicitly instruct the session to load that specific module. After this you can use the PnP Powershell commands as usual. When wanting to switch to a different SharePoint version in the same Powershell window, explicitly unload the one you were using first using:

remove-module SharePointPnPPowerShellOnline

And then do an import-module for the other version you want to use.

Only if you follow these steps carefully, you can make it work. This is Powershell as it has been designed and has nothing to do with PnP Powershell specifically.

Hope this helps.