Last active
October 31, 2017 17:18
-
-
Save crossan007/76b62e4c0b1838fe2f6455e4a9bb98c7 to your computer and use it in GitHub Desktop.
Unapprove previously approved forms which are now pending
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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