Pnp-powershell: New-PnPSite error "Could not load file or assembly"

Created on 20 May 2020  路  8Comments  路  Source: pnp/PnP-PowerShell

Reporting an Issue or Missing Feature

Reporting an Error. This issue started today after using the latest MSI from GitHub to update existing module (also installed via MSI). Process has worked flawlessly until the update.

Expected behavior

A new PnP site would be created in the target SharePoint Online tenant

Actual behavior

After successfully connecting to the SPO service and the PnPOnline service, attempting to execute New-PnPSite throws a fatal error and no site is provisioned.

Steps to reproduce behavior

Basic process is thus:

$SPOService = Connect-SPOService -Url [admin url] -Credential [admin creds]
$PNPConnection = Connect-PnPOnline -Url [spo root] -ReturnConnection -SPOManagementShell
New-PnPSite -Type TeamSite -Title 'My Site Title' -Alias 'MySiteTitle' -Description 'MySiteDescription' -Connection $PNPConnection
New-PnPSite : Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Which version of the PnP-PowerShell Cmdlets are you using?

  • [ ] PnP PowerShell for SharePoint 2013
  • [ ] PnP PowerShell for SharePoint 2016
  • [ X ] PnP PowerShell for SharePoint Online

What is the version of the Cmdlet module you are running?

3.20.2004.0

How did you install the PnP-PowerShell Cmdlets?

  • [X] MSI Installed downloaded from GitHub
  • [ ] Installed through the PowerShell Gallery with Install-Module
  • [ ] Other means
fixed-next-drop bug

Most helpful comment

Thanks for reporting this @etherjack ! We've found the cause and it will be fixed in the June release which is expected to happen on June 9th, 2020.

All 8 comments

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@etherjack Works fine here on the latest version using Install-Module. Don't have the ability to try out the MSI at the moment. Are you able to give it a try by uninstalling the MSI and then running Install-Module SharePointPnPPowerShellOnline on your machine to see if it works after doing this?

I am running PS v4 and have had limited success using the PowershellGet module cmdlets. I'll give it another go.

Result (running console as admin):

PS C:\> Install-Module SharePointPnPPowerShellOnline
WARNING: Repository location 'https://www.powershellgallery.com/api/v2' is not valid for this provider.
WARNING: Unable to resolve module repository 'https://www.powershellgallery.com/api/v2'.
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'SharePointPnPPowerShellOnline'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSGet.psm1:1009 char:21
+             $null = PackageManagement\Install-Package @PSBoundParameters
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Try the TLS fix in this post.

Getting an error now indicating an issue finding the latest version. Should I specify a version explicitly?

PS C:\> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS C:\> Install-Module SharePointPnPPowerShellOnline -Scope AllUsers

Untrusted repository.
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install
 the modules from 'https://www.powershellgallery.com/api/v2'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A
WARNING: NuGet: System.InvalidOperationException: Unable to find version '3.21.2005.2' of package 'SharePointPnPPowerShellOnline'.
WARNING: NuGet:    at NuGet.PackageRepositoryHelper.ResolvePackage(IPackageRepository sourceRepository, IPackageRepository localRepository, IPackageConstraintProvider constraintProvider, String
packageId, SemanticVersion version, Boolean allowPrereleaseVersions)
WARNING: NuGet:    at NuGet.PackageManager.InstallPackage(String packageId, SemanticVersion version, Boolean ignoreDependencies, Boolean allowPrereleaseVersions)
WARNING: NuGet:    at NuGet.Commands.InstallCommand.InstallPackage(IFileSystem fileSystem, String packageId, SemanticVersion version)
WARNING: NuGet:    at NuGet.Program.Main(String[] args)

Not sure what's going on there. Seems like a connection issue. I've started a VM and installed the MSI and am able to reproduce the error you're seeing using the MSI. I'll flag it to have a look at it with Erwin next Friday. The issue does not exist in the Install-Module version.

Thanks for reporting this @etherjack ! We've found the cause and it will be fixed in the June release which is expected to happen on June 9th, 2020.

Was this page helpful?
0 / 5 - 0 ratings