Error when using PnP powershell and CSOM

%3CLINGO-SUB%20id%3D%22lingo-sub-33781%22%20slang%3D%22en-US%22%3EError%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33781%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20out%20the%20%22O365%20Intranet%20starter%22%20from%20PnP.%3C%2FP%3E%3CP%3EAlmost%20everything%20is%20working%20just%20fine%2C%20but%20i%20have%20some%20issues.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20function%20expects%20a%20Web%20object%20(Get-PnPWeb%20is%20the%20same%20as%20the%20%22old%22%20Get-SPOWeb)%3A%3C%2FP%3E%3CPRE%3Efunction%20Enable-CustomItemScheduling%20%7B%0A%5BCmdletBinding()%5D%0A%20%20%20%20Param(%0A%20%20%20%20%20%20%20%20%5BParameter(Mandatory%3D%24true)%5D%0A%20%20%20%20%20%20%20%20%5BMicrosoft.SharePoint.Client.Web%5D%24Web%2C%0A%20%20%20%20%20%20%20%20%5BParameter(Mandatory%3D%24true)%5D%0A%20%20%20%20%20%20%20%20%5BString%5D%24PagesLibraryName%0A%20%20%20%20)%20%3C%2FPRE%3E%3CP%3EAnd%20it's%20being%20called%20like%20this%3A%3C%2FP%3E%3CPRE%3EEnable-CustomItemScheduling%20-Web%20(Get-PnPWeb)%20-PagesLibraryName%20%22Pages%22%3C%2FPRE%3E%3CP%3EIt%20might%20be%20a%20.dll%20issue(%3F)%2C%20but%20I%20don't%20know%20how%20to%20tell%2C%20but%20this%20is%20the%20error%20I%20get%3A%3C%2FP%3E%3CPRE%3E%22Cannot%20convert%20the%20%22Microsoft.SharePoint.Client.Web%22%20value%20of%20type%20%22Microsoft.SharePoint.Client.Web%22%20to%20type%20%22Microsoft.SharePoint.Client.Web%22%3C%2FPRE%3E%3CP%3EI've%20tried%20playing%20around%20with%20the%20cmdlet%20and%20passing%20as%20a%20Microsoft.SharePoint.Client.Web%2C%20but%20the%20same%20error%20exists.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20installed%3A%3C%2FP%3E%3CUL%3E%3CLI%3ESharePoint%20online%20sdk%3C%2FLI%3E%3CLI%3ESharePoint%20Online%20Management%20Shell%3C%2FLI%3E%3CLI%3EHave%20rebuilt%20the%20%22custom%22%20.dll%20that%20is%20utilized%20in%20the%20deployment%20with%20the%20newest%20SharePoint%20Online%20Nuget%3C%2FLI%3E%3CLI%3EDownloaded%20the%20latest%20PnP%20Powershell%20and%20installed%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20anyone%20knows%20where%20I%20should%20start%20looking%2C%20it%20would%20be%20most%20helpful%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2FSimon%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-393698%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Error%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-393698%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F122%22%20target%3D%22_blank%22%3E%40Erwin%20van%20Hunen%3C%2FA%3E%20%26nbsp%3B%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EI%20uninstalled%20SPO%20Client%20Component%20SDK%20but%20still%20getting%20the%20same%20error.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33869%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Error%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33869%22%20slang%3D%22en-US%22%3E%3CP%3EYeah%2C%20I%20removed%20the%20dlls%20from%20the%20GAC.%3C%2FP%3E%3CP%3EManagement%20Shell%20Loaded%20the%20.dlls%20from%20%22C%3A%5CProgram%20Files%5CSharePoint%20Online%20Management%20Shell%5CMicrosoft.Online.SharePoint.PowerShell%5C%22%2C%20and%20they%20we're%20old.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20anyway%2C%20thank%20you%20for%20the%20help%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2FSImon%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33859%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Error%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33859%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20the%20assemblies%20are%20available%20in%20the%20GAC%20(which%20happens%20if%20you%20install%20the%20CSOM%20SDK)%2C%20those%20will%20always%20be%20used%20before%20files%20available%20in%20the%20folder.%20That's%20the%20main%20problem%20with%20the%20GAC%20and%20that's%20why%20the%20SharePoint%20Online%20Management%20Shell%20uses%20those%20old%20assemblies.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33858%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Error%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33858%22%20slang%3D%22en-US%22%3E%3CP%3ESharePoint%20Online%20Management%20Shell%20loaded%2Ftried%20to%20load%26nbsp%3Bthe%2016.0.0.0%20version%20of%20the%20.dll%3As%3CBR%20%2F%3EI%20deleted%20the%20dlls%20and%20just%20didn't%20care%20about%20the%20error%20message%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EImport-Module%20%3A%20Could%20not%20load%20file%20or%20assembly%20'Microsoft.SharePoint.Client%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%0APublicKeyToken%3D71e9bce111e9429c'%20or%20one%20of%20its%20dependencies.%20The%20system%20cannot%20find%20the%20file%20specified.%0AAt%20line%3A1%20char%3A1%0A%2B%20Import-Module%20Microsoft.Online.SharePoint.PowerShell%20-DisableNameChec%20...%3C%2FPRE%3E%3CP%3EThen%20I%20tried%20a%20simple%20(that%20worked)%3A%3C%2FP%3E%3CPRE%3E%5BMicrosoft.SharePoint.Client.Web%5D%24web%20%3D%20Get-PnPWeb%3C%2FPRE%3E%3CP%3ESo%20indeed%20it%20was%20a%20.dll%20mismatch%2C%20but%20why%20did%20SharePoint%20Management%20Shell%20try%20to%20load%20so%20old%20assemblies%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2FSimon%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33847%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Error%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33847%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can%20absolutely%20still%20use%20the%20SharePoint%20Online%20Management%20shell.%20One%20of%20the%20reasons%20we%20renamed%20the%20cmdlets%20from%20*-SPO*%20to%20*-PnP*%20is%20to%20be%20able%20to%20use%20them%20side%20by%20side%20without%20conflicts.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33846%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Error%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33846%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20reply!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20uninstall%20the%20%22SharePoint%20Client%20Component%22.%3CBR%20%2F%3ECan%20I%20still%20use%20the%20%22SharePoint%20Online%20Management%20shell%22%2C%20or%20can%20it%20also%20cause%20a%20conflict%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20to%20know%20about%20the%20latest%20SDK%20being%20included%20in%20the%20PnP%20package.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3ESimon%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33845%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Error%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33845%22%20slang%3D%22en-US%22%3E%3CP%3EInitially%20this%20feels%20like%20a%20conflict%20between%20the%20various%20versions%20of%20the%20CSOM%20sdk.%20The%20PnP%20Cmdlets%20come%20with%20the%20CSOM%20SDK%20included%2C%20so%20you%20don't%20have%20to%20install%20that%20SDK.%20The%20downloadable%20SDK%20is%20most%20likely%20also%20older%20than%20the%20one%20that%20comes%20with%20the%20PnP%20Cmdlets%20(the%20PnP%20cmdlets%20are%20always%20using%20the%20latest%20SDK%2C%20usually%20before%20the%20downloadable%20package%20is%20updated%20by%20MS).%20My%20initial%20try%20would%20be%20to%20uninstall%20the%20SDK%20(which%20installs%20the%20SDK%20into%20the%20GAC%2C%20which%20is%20generally%20a%20'bad'%20thing).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33842%22%20slang%3D%22en-US%22%3ERE%3A%20Error%20when%20using%20PnP%20powershell%20and%20CSOM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33842%22%20slang%3D%22en-US%22%3EGodfather%20PowerShell%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F122%22%20target%3D%22_blank%22%3E%40Erwin%20van%20Hunen%3C%2FA%3E%20Any%20clue%3F%20%3A)%3C%2Fimg%3E%3C%2FLINGO-BODY%3E
Highlighted
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
Highlighted
Godfather PowerShell @Erwin van Hunen Any clue? :)
Highlighted

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

Highlighted

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

 

Highlighted

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.

Highlighted

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

 

Highlighted

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.

Highlighted

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

Highlighted

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