Forum Discussion
Sep 20, 2016
Add-SPOFile fails with format-default : The collection has not been initialized...
Using the PnP PowerShell CmdLets I'm trrying to add a Word document to a library. When I run the following line as part of a larger script: Add-SPOFile -Path $path/DocumentTemplates/MyTemplate.do...
- Sep 20, 2016
you're not surpressing error messages in your script? As such it doesn't have to a be a blocking error. The cmdlet just outputs an object where one of the properties has not been loaded by CSOM. The object is still there. The simplest solution is to assign the output of the cmdlet into a variable:
$file = Add-SPOFile etc. etc.
That will 'swallow' the error message and put the resulting object into the $file variable. You will receive the same error when you simply output the results of the $file variable to the output.
Sep 20, 2016
Thanks, that fixed the issue. I understand that for PowerShell to present the object to me it isn't able to get to all of the data (not initialized). Still a bit unclear though why it would work when I run it from the Console in PowerShell ISE and not directly in a script.