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?