Powershell Query _ModerationStatus for Sharepoint List

%3CLINGO-SUB%20id%3D%22lingo-sub-564009%22%20slang%3D%22en-US%22%3EPowershell%20Query%20_ModerationStatus%20for%20Sharepoint%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-564009%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%26nbsp%3B%20new%20to%20SP%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20powershell%20to%20pull%20list%20and%20would%20like%20to%20get%20moderation%20status%20from%20list%20of%20items%2C%20so%20I%20can%20do%20some%20work%20on%20that%20item%20if%20its%20in%20a%20non-approved%20state.%20Using%20SP%20Online%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24orgName%3D%22myorganization%22%3CBR%20%2F%3E%24UserCredential%20%3D%20Get-Credential%20-Credential%20myname%40myorganization.com%3C%2FP%3E%3CP%3EConnect-PnPOnline%20-url%20https%3A%2F%2F%24orgName-admin.sharepoint.com%20-Credential%20%24userCredential%3C%2FP%3E%3CP%3E%24mysiteurl%3D%22%3CA%20href%3D%22https%3A%2F%2Fmyorganization.sharepoint.com%2Fsites%2FtargetSiteApproval%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmyorganization.sharepoint.com%2Fsites%2FtargetSiteApproval%3C%2FA%3E%22%3CBR%20%2F%3E%24listname%3D%22TeamsApprovalsList%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eget-pnplist%20-Identity%20%24listname%3C%2FP%3E%3CP%3EGet-PnPField%20-list%20'Target%20Approvals%20List'%3C%2FP%3E%3CP%3EGet-PnPListItem%20-list%201234-4567-8919-4567%20%23%20my%20guid%20for%20the%20site%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20dont%20see%20where%20I%20can%20get%20to%20the%20moderation%20status%2C%20I%20just%20get%20ID%2C%20Title%20and%20GUID.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20assume%20some%20sort%20of%20get-pnplistitem%20-list%20guide%20-item%2030%20-field%20%22_ModerationStatus%22%3C%2FP%3E%3CP%3Ebut%20I%20dont%20see%20it%2C%20what%20am%20I%20missing%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20assuming%20when%20I%20get%20to%20moderationstatus%20it%20will%20be%20a%20numeric%20value%200-4%2C%20but%20I%20cant%20seem%20to%20pull%20it%20out%20of%20the%20list.%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%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-570387%22%20slang%3D%22en-US%22%3ERe%3A%20Powershell%20Query%20_ModerationStatus%20for%20Sharepoint%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-570387%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F341476%22%20target%3D%22_blank%22%3E%40justjeff%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20SharePoint%20Online%2C%20the%20field%20you%20are%20looking%20for%20is%20'OData__ModerationStatus'.%26nbsp%3B%20I'm%20not%20sure%20why%20they%20changed%20the%20name%2C%20but%20they%20did.%26nbsp%3B%20Important%20Note%3A%20that%20is%20a%20%22double%20underscore%22%20between%20the%20words.%26nbsp%3B%20And%20yes%2C%20it%20returns%20a%20number%2C%20where%200%20means%20'Approved'.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello,  new to SP

 

Using powershell to pull list and would like to get moderation status from list of items, so I can do some work on that item if its in a non-approved state. Using SP Online

 

$orgName="myorganization"
$UserCredential = Get-Credential -Credential myname@myorganization.com

Connect-PnPOnline -url https://$orgName-admin.sharepoint.com -Credential $userCredential

$mysiteurl="https://myorganization.sharepoint.com/sites/targetSiteApproval"
$listname="TeamsApprovalsList"

 

get-pnplist -Identity $listname

Get-PnPField -list 'Target Approvals List'

Get-PnPListItem -list 1234-4567-8919-4567 # my guid for the site

 

I dont see where I can get to the moderation status, I just get ID, Title and GUID.

 

I would assume some sort of get-pnplistitem -list guide -item 30 -field "_ModerationStatus"

but I dont see it, what am I missing?

 

I am assuming when I get to moderationstatus it will be a numeric value 0-4, but I cant seem to pull it out of the list.

 

 

 

 

 

 

1 Reply

@justjeff 

 

For SharePoint Online, the field you are looking for is 'OData__ModerationStatus'.  I'm not sure why they changed the name, but they did.  Important Note: that is a "double underscore" between the words.  And yes, it returns a number, where 0 means 'Approved'.