Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unapprove previously approved forms which are now pending
$Web = Get-SPWeb "https://somesite.someorg.org/somesubsite"
$List = $web.Lists.TryGetList("Forms")
$Items = $List.Items | Where-Object {$_.ModerationInformation.Status -eq "Pending" -and $(Test-HasPreviousPublished -Item $_)}
Function Test-HasPreviousPublished {
Param(
$Item
)
Foreach ($Version in $Item.Versions)
{
if ($Version.Level -eq "Published")
{
return $true
}
}
return $false
}
Foreach($Item in $Items)
{
$Item.File.TakeOffline()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment