PowerShell Csom load property Issue

fredericdietrich By On 18/01/2019

Using  Microsoft.SharePoint.Client.dll  you can have issue after object loading

$file = $oWeb.GetFileByUrl($fileUrl);

$context.Load($file);

$context.ExecuteQuery()

$context.Load($file.ListItemAllFields)

$context.ExecuteQuery()

$file.ListItemAllFields #accessing to this property will thow exception below

format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

 

so you have to store property in a variable like that

 

$ListItemAllFields = $file.ListItemAllFields

$context.Load($ListItemAllFields)

$context.ExecuteQuery()

 

 

 

 

powershell Sharepoint

  • No ratings yet - be the first to rate this.