Forum Discussion
PnP PowerShell modules
- Dec 14, 2016
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.
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
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
Confirm
Are you sure you want to perform this action?
Performing the operation "Uninstall-Module" on target "Version '2.11.1701.1' of module
'SharePointPnPPowerShellOnline'".
[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\1.0.0.1\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
Package
This confuses me as I am not running any PnpCommandlets .. Do I need to remove-module before uninstalling it?
- Mar 01, 2017
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)
- Daniel WesterdaleMar 01, 2017Iron Contributor
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