PnP PowerShell modules

Silver Contributor

When I run get-module -ListAvailable, I get the following:

Script     2.10.16... SharePointPnPPowerShellOnline       {Get-PnPWebTemplates, Get-PnPTimeZoneId, Set-PnPTenantSite, Uninstall-PnPAppInstance...}                       
Binary     2.8.1610.0 SharePointPnPPowerShellOnline       {Get-PnPWebTemplates, Get-PnPTimeZoneId, Set-PnPTenantSite, Uninstall-PnPAppInstance...}        


 I think i did something wrong, but I'm not sure what. Can anyone tell me why I would have one module that is a Script type and another that is Binary? I think that I should only have one. I can't figure out how to remove the older one (the binary)            

7 Replies
best response confirmed by VI_Migration (Silver Contributor)

Hi @Dean Gross,


it looks like you've got two versions installed.


you might want to try the following:



$modules = get-module -ListAvailable | where {$_.Name -eq "SharePointPnPPowerShellOnline"}
foreach($module in $modules)
   Write-Host $module.Name $module.Path


This should give you the location of the modules.



@Pieter Veenstra @Dean Gross


I am doing a bit of house keeping and had a similar thoughts.

I had previously run this but now prefer your script


Get-Module -ListAvailable -Name *SharePoint*

Ok, in my case I see this


ModuleType Version    Name                                ExportedCommands        
---------- -------    ----                                ----------------        
Script     2.11.17... SharePointPnPPowerShellOnline       {Get-PnPWebTemplates, ...
Script     2.9.1611.0 SharePointPnPPowerShellOnline       {Get-PnPWebTemplates, ...
Binary     2.6.1608.0 SharePointPnPPowerShellOnline       {Get-PnPWebTemplates, ...


Now I want either


1) remove/ uninstall  a version of the module but this doesn't seem to work exactly :

Remove-Module -FullyQualifiedName @{ModuleName = 'SharePointPnPPowerShellOnline'; ModuleVersion = '2.9.1611.0'}

Previously I have simply deleted the module in question  from the modules dir but there must be a more elegant way to do this ...




2) I want to keep all versions but be able to set the default module in a script or accross all scripts in a session

( I would hate to add a path to each commmand Smiley Sad)


Hi @Daniel Westerdale,


I quite often use the following lines in my scripts to set the ModulePath to include the Modules folder to includee my custom modules. You could probably do something similar to control the different versions of modules. 




$path = Split-Path -parent $MyInvocation.MyCommand.Definition

if ($env:PSModulePath -notlike "*$path\Modules\*")
"Adding ;$path\Modules to PSModulePath" | Write-Debug 
$env:PSModulePath += ";$path\Modules\"
Write-Host $env:PSModulePath



@Pieter Veenstra


Ok I can see you have argumented the current module path to allow any custom modules to be accessed. I like it.


In this case I have a couple of versions of PnPCommandlets in my main module directory. I am thinking intellisense will still pick up each duplicated command and therein is my issue.  So I can move the older modules from this dir and then deploy your approach in making them seen in the path. Alternativley I simple delete them. Just seems a a bit odd I can' uninstall/remove a version of a module or move it out of the path with a simple command sequence. Maybe I should write this Smiley Frustrated




Hi @Pieter Veenstra 


I had a spring clean today of my PnpCommandlets as I want to ensure I stick to the new syntax Anyway I uninstalled each of the older versions and then I   ran the update-module. Doh! I now have 2 versions installed. Ok, I will try remove the older one so do this the interactive way.



uninstall-module SharePointPnPPowerShellOnline -AllVersions -Confirm


Are you sure you want to perform this action?
Performing the operation "Uninstall-Module" on target "Version '2.11.1701.1' of module
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
WARNING: The version '2.11.1701.1' of module 'SharePointPnPPowerShellOnline' is currently in use. Retry the operation
after closing the applications.
PackageManagement\Uninstall-Package : Module 'SharePointPnPPowerShellOnline' is in currently in use.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\\PSModule.psm1:2157 char:21
+ ... $null = PackageManagement\Uninstall-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Packag
e], Exception
+ FullyQualifiedErrorId : ModuleIsInUse,Uninstall-Package,Microsoft.PowerShell.PackageManagement.Cmdlets.Uninstall


This confuses me as I am not running any PnpCommandlets .. Do I need to remove-module before uninstalling it? 



@Daniel Westerdale, it looks like that version has been installed with an installer. 


You're getting the error becsause the modules have been loaded wihtin a PowerShell session. You could try closing all PowerShell session. ( Check Task Manager for anything PowerShell like)


Then I would try and deinstall using the installer ( Add/remove programs)

@Pieter Veenstra



Yes you were spot on .. even though I had closed ISE it was still present in the Task Manager.  I ran a Cmder PS Console window  for a change and it the above command has removed all SharePointPnPPowerShellOnline modules which suprised me as I thought I would be prompted for the one I wanted to keep.  I installed the latest and greatest .. Thanks for you help