Cannot convert the "Microsoft.SharePoint.Client.ListItem" value of type "Microsoft.SharePoint.Clien

%3CLINGO-SUB%20id%3D%22lingo-sub-1622351%22%20slang%3D%22en-US%22%3ECannot%20convert%20the%20%22Microsoft.SharePoint.Client.ListItem%22%20value%20of%20type%20%22Microsoft.SharePoint.Clien%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1622351%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20we%20run%20the%20below%20script%20on%20the%20Power%20shell%20version%205.1%20for%20fetching%20file%20property.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%20%20workflow%20IterateWorkflow%20%0A%7B%0A%20%20%20%20Parallel%20%7B%0A%20%20%20%20%20%20%20%20Connect-PnPOnline%20-Url%20%24SrcFolderURL%20-Credentials%20%20%24creds%20-ErrorAction%20SilentlyContinue%20-WarningAction%20SilentlyContinue%0A%20%20%20%20%20%20%20%20%24folderUrl%20%3D%20%22%2FDocuments%2FIt's%20a%20level%203%20folder%20for%20testing%2FLevel%204%2Ffile-sample_100kB.doc%22%0A%20%20%20%20%20%20%20%20%24file%20%3D%20Get-PnPFile%20-Url%20%24folderUrl%20-AsListItem%0A%20%20%20%20%20%20%20%20if%20(%24file)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Get-PnPProperty%20-ClientObject%20%24file%20-Property%20HasUniqueRoleAssignments%2C%20RoleAssignments%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24file%20%3D%20Get-PnPFile%20-Url%20%24folderUrl%20-AsListItem%0A%20%20%20%20%20%20%20%20%20%20%20%20Get-PnPProperty%20-ClientObject%20%24file%20-Property%20HasUniqueRoleAssignments%2C%20RoleAssignments%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20getting%20Microsoft%20related%20issue%2C%26nbsp%3B%20however%2C%20its%20running%20successful%20on%20%3CSTRONG%3Enon-workflow%3C%2FSTRONG%3E%20the%20Power%20Shell.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ECannot%20bind%20parameter%20'ClientObject'.%20Cannot%20convert%20the%20%22Microsoft.SharePoint.Client.ListItem%22%20value%20of%20type%20%22Deserialized.Microsoft.SharePoint.Client.ListItem%22%20to%20type%20%22Microsoft.SharePoint.Client.ClientObject%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1622351%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%20ISE%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

When we run the below script on the Power shell version 5.1 for fetching file property.

 

 

 

 

  workflow IterateWorkflow 
{
    Parallel {
        Connect-PnPOnline -Url $SrcFolderURL -Credentials  $creds -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
        $folderUrl = "/Documents/It's a level 3 folder for testing/Level 4/file-sample_100kB.doc"
        $file = Get-PnPFile -Url $folderUrl -AsListItem
        if ($file) {
            Get-PnPProperty -ClientObject $file -Property HasUniqueRoleAssignments, RoleAssignments
        }
        else {
            $file = Get-PnPFile -Url $folderUrl -AsListItem
            Get-PnPProperty -ClientObject $file -Property HasUniqueRoleAssignments, RoleAssignments
        }
    }
}

 

 

 

 

We are getting Microsoft related issue,  however, its running successful on non-workflow the Power Shell.

 

 

 

Cannot bind parameter 'ClientObject'. Cannot convert the "Microsoft.SharePoint.Client.ListItem" value of type "Deserialized.Microsoft.SharePoint.Client.ListItem" to type "Microsoft.SharePoint.Client.ClientObject"

 

 

0 Replies