Can we have both SharePointPnPPowerShellOnline and PnP.PowerShell installed in same machine?

Hirdesh Baghel 20 Reputation points
2024-09-03T09:57:36.1466667+00:00

Hi,

I am working with SharePoint PowerShell Modules to create some PowerShell Scripts, I want to know if we can install both SharePointPnPPowerShellOnline and PnP.PowerShell installed in same machine. I am using some cmdlets from SharePointPnPPowerShellOnline and at the same time I am using some cmdlets from PnP.PowerShell.

I know that cmdlets that are part of SharePointPnPPowerShellOnline are also part of PnP.PowerShell. Can we install both in same machine ? if yes, Is there any way where we can mention that we want use the cmdlet from specific module?

Any help on this will be highly appreciated.

Thanks

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,958 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,489 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Wesley Li 8,455 Reputation points
    2024-09-03T14:24:58.2233333+00:00

    Hello,

    Yes, you can install both SharePointPnPPowerShellOnline and PnP.PowerShell on the same machine. However, you need to be careful when using cmdlets from both modules to avoid conflicts.

    To specify which module a cmdlet should be used from, you can use the Module parameter in the Import-Module cmdlet or use the fully qualified cmdlet name. Here are examples of both methods:

    1.Using the Module parameter:

    Import-Module SharePointPnPPowerShellOnline

    Import-Module PnP.PowerShell

    # Use cmdlet from SharePointPnPPowerShellOnline

    Get-PnPWeb -Module SharePointPnPPowerShellOnline

    # Use cmdlet from PnP.PowerShell

    Get-PnPWeb -Module PnP.PowerShell

    2.Using the fully qualified cmdlet name:

    # Use cmdlet from SharePointPnPPowerShellOnline

    SharePointPnPPowerShellOnline\Get-PnPWeb

    # Use cmdlet from PnP.PowerShell

    PnP.PowerShell\Get-PnPWeb

    By specifying the module, you can ensure that the correct cmdlet is used from the desired module. This approach helps avoid any conflicts that may arise from having both modules installed on the same machine.


  2. Alvaro Avila 75 Reputation points
    2024-09-04T08:08:31.34+00:00

    Technically PowerShell 7 keeps the modules separated from the classic PowerShell.

    you can have the legacy PnP module on your classic PowerShell, which new PnP.PowerShell installed on PowerShell 7.

    Actually PnP.PowerShell only works in PowerShell 7 since v2.0, while the legacy was never migrated.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.