pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

New-PnPSite error "Could not load file or assembly" #2685

Closed ghost closed 4 years ago

ghost commented 4 years ago

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?

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

3.20.2004.0

How did you install the PnP-PowerShell Cmdlets?

ghost commented 4 years ago

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

KoenZomers commented 4 years ago

@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?

ghost commented 4 years ago

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

ghost commented 4 years ago

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
ToddKlindt commented 4 years ago

Try the TLS fix in this post.

ghost commented 4 years ago

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)
KoenZomers commented 4 years ago

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.

KoenZomers commented 4 years ago

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.