Forum Discussion

Dean_Gross's avatar
Dean_Gross
Silver Contributor
Dec 13, 2016

PnP PowerShell modules

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)            

  • 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 Westerdale's avatar
      Daniel Westerdale
      Iron Contributor

      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 ...

       

      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:)

      .

      • Pieter Veenstra's avatar
        Pieter Veenstra
        MVP

        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

         

         

Resources