Forum Discussion

Pieter Veenstra's avatar
Sep 20, 2016
Solved

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...
  • Erwin van Hunen's avatar
    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.

     

     

Resources