Get-PnPListItem Value cannot be null

%3CLINGO-SUB%20id%3D%22lingo-sub-1152583%22%20slang%3D%22en-US%22%3EGet-PnPListItem%20Value%20cannot%20be%20null%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1152583%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20hit%20an%20issue%20in%20a%20couple%20of%20document%20libraries%20when%20running%20Get-PnPListItem%20to%20retrieve%20all%20documents%20I%20get%20a%20%22Value%20cannot%20be%20null%22%20response%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24items%20%3D%20Get-PnPListItem%20-List%20%22Shared%20Documents%22%20-PageSize%20500%3C%2FP%3E%3CP%3EGet-PnPListItem%20%3A%20Value%20cannot%20be%20null.%3CBR%20%2F%3EParameter%20name%3A%20termId%3CBR%20%2F%3EAt%20line%3A1%20char%3A10%3CBR%20%2F%3E%2B%20%24items%20%3D%20Get-PnPListItem%20-PageSize%20500%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20WriteError%3A%20(%3A)%20%5BGet-PnPListItem%5D%2C%20ServerException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20EXCEPTION%2CSharePointPnP.PowerShell.Commands.Lists.GetListItem%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHas%20anyone%20seen%20this%20before%3F%20IS%20there%20any%20way%20of%20determining%20what%20item%2Fterm%20is%20causing%20the%20error%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1152583%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1156540%22%20slang%3D%22en-US%22%3ERe%3A%20Get-PnPListItem%20Value%20cannot%20be%20null%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1156540%22%20slang%3D%22en-US%22%3E%3CP%3EHey%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F545955%22%20target%3D%22_blank%22%3E%40jrmcloughlin%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%20few%20questions%20to%20help%20understand%20your%20problem%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EAre%20you%20using%20the%20latest%20version%20of%20PnP%20PowerShell%3F%26nbsp%3B%3C%2FLI%3E%3CLI%3EDoes%20this%20problem%20happen%20only%20to%20the%20Shared%20Documents%20library%3F%3C%2FLI%3E%3CLI%3EDo%20you%20have%20permission%20to%20read%2F%20edit%20this%20list%3F%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1157852%22%20slang%3D%22en-US%22%3ERe%3A%20Get-PnPListItem%20Value%20cannot%20be%20null%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1157852%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F365643%22%20target%3D%22_blank%22%3E%40Carlos_Marins%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EYes%3C%2FLI%3E%3CLI%3EShared%20Documents%20is%20the%20only%20library%20we%20have%20on%20each%20site.%20We%20have%20hundreds%20of%20sites%20and%20I've%20only%20seen%20this%20issue%20on%202%20of%20them%3C%2FLI%3E%3CLI%3EI'm%20site%20collection%20admin%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1159012%22%20slang%3D%22en-US%22%3ERe%3A%20Get-PnPListItem%20Value%20cannot%20be%20null%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1159012%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F545955%22%20target%3D%22_blank%22%3E%40jrmcloughlin%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20making%20a%20quick%20search%20all%20I%20could%20find%20was%20this%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F254766%2Fsp2013-value-cannot-be-null-error-for-version-history-on-a-single-document%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Equestion%3C%2FA%3E%26nbsp%3Bon%20Stack%20Exchange.%20It%20seems%20like%20a%20single%20item%20could%20be%20causing%20problem%20due%20to%20its%20metadata.%20Can%20you%20try%20to%20query%20a%20single%20item%20from%20this%20library%20and%20see%20if%20it%20works%3F%20Maybe%20by%20querying%20different%20items%20you%20can%20track%20it%20down%20to%20a%20single%20file%20that's%20causing%20the%20issue.%20Let%20me%20know%20if%20it%20helps.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I've hit an issue in a couple of document libraries when running Get-PnPListItem to retrieve all documents I get a "Value cannot be null" response:

 

$items = Get-PnPListItem -List "Shared Documents" -PageSize 500

Get-PnPListItem : Value cannot be null.
Parameter name: termId
At line:1 char:10
+ $items = Get-PnPListItem -PageSize 500
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Get-PnPListItem], ServerException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Lists.GetListItem

 

Has anyone seen this before? IS there any way of determining what item/term is causing the error?

3 Replies

Hey @jrmcloughlin,

 

A few questions to help understand your problem:

 

  • Are you using the latest version of PnP PowerShell? 
  • Does this problem happen only to the Shared Documents library?
  • Do you have permission to read/ edit this list?

 

Regards,

@Carlos_Marins 

  • Yes
  • Shared Documents is the only library we have on each site. We have hundreds of sites and I've only seen this issue on 2 of them
  • I'm site collection admin

Thanks

Hi @jrmcloughlin ,

 

So, making a quick search all I could find was this question on Stack Exchange. It seems like a single item could be causing problem due to its metadata. Can you try to query a single item from this library and see if it works? Maybe by querying different items you can track it down to a single file that's causing the issue. Let me know if it helps.

 

Regards