Error when using PnP powershell and CSOM

Deleted
Not applicable

Hi,

 

I am trying out the "O365 Intranet starter" from PnP.

Almost everything is working just fine, but i have some issues.

 

This function expects a Web object (Get-PnPWeb is the same as the "old" Get-SPOWeb):

function Enable-CustomItemScheduling {
[CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true)]
        [Microsoft.SharePoint.Client.Web]$Web,
        [Parameter(Mandatory=$true)]
        [String]$PagesLibraryName
    ) 

And it's being called like this:

Enable-CustomItemScheduling -Web (Get-PnPWeb) -PagesLibraryName "Pages"

It might be a .dll issue(?), but I don't know how to tell, but this is the error I get:

"Cannot convert the "Microsoft.SharePoint.Client.Web" value of type "Microsoft.SharePoint.Client.Web" to type "Microsoft.SharePoint.Client.Web"

I've tried playing around with the cmdlet and passing as a Microsoft.SharePoint.Client.Web, but the same error exists.

 

I have installed:

  • SharePoint online sdk
  • SharePoint Online Management Shell
  • Have rebuilt the "custom" .dll that is utilized in the deployment with the newest SharePoint Online Nuget
  • Downloaded the latest PnP Powershell and installed

 

If anyone knows where I should start looking, it would be most helpful

 

/Simon

 

8 Replies
Godfather PowerShell @Erwin van Hunen Any clue? :)

Initially this feels like a conflict between the various versions of the CSOM sdk. The PnP Cmdlets come with the CSOM SDK included, so you don't have to install that SDK. The downloadable SDK is most likely also older than the one that comes with the PnP Cmdlets (the PnP cmdlets are always using the latest SDK, usually before the downloadable package is updated by MS). My initial try would be to uninstall the SDK (which installs the SDK into the GAC, which is generally a 'bad' thing).

Thanks for the reply!

 

I will uninstall the "SharePoint Client Component".
Can I still use the "SharePoint Online Management shell", or can it also cause a conflict?

 

Good to know about the latest SDK being included in the PnP package.

 

Regards

Simon

 

You can absolutely still use the SharePoint Online Management shell. One of the reasons we renamed the cmdlets from *-SPO* to *-PnP* is to be able to use them side by side without conflicts.

SharePoint Online Management Shell loaded/tried to load the 16.0.0.0 version of the .dll:s
I deleted the dlls and just didn't care about the error message:

 

Import-Module : Could not load file or assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
At line:1 char:1
+ Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChec ...

Then I tried a simple (that worked):

[Microsoft.SharePoint.Client.Web]$web = Get-PnPWeb

So indeed it was a .dll mismatch, but why did SharePoint Management Shell try to load so old assemblies?

 

/Simon

 

If the assemblies are available in the GAC (which happens if you install the CSOM SDK), those will always be used before files available in the folder. That's the main problem with the GAC and that's why the SharePoint Online Management Shell uses those old assemblies.

Yeah, I removed the dlls from the GAC.

Management Shell Loaded the .dlls from "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\", and they we're old.

 

But anyway, thank you for the help :)

 

/SImon

@Erwin van Hunen  I uninstalled SPO Client Component SDK but still getting the same error.