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.
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.
- Daniel WesterdaleJan 23, 2017Iron Contributor
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 ...
or
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 :smileysad:)
.
- Jan 24, 2017
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- Daniel WesterdaleMar 01, 2017Iron Contributor
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
PackageThis confuses me as I am not running any PnpCommandlets .. Do I need to remove-module before uninstalling it?