Skip to content

Instantly share code, notes, and snippets.

@crossan007
Last active October 31, 2017 17:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save crossan007/76b62e4c0b1838fe2f6455e4a9bb98c7 to your computer and use it in GitHub Desktop.
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