Skip to content

Instantly share code, notes, and snippets.

@vaderj
Last active June 12, 2018 17:06
Show Gist options
  • Save vaderj/e687a72da41b373d0b1b to your computer and use it in GitHub Desktop.
Save vaderj/e687a72da41b373d0b1b to your computer and use it in GitHub Desktop.
Check-in / Publish / Approve all docs in a given lib #PowerShell #SharePoint #SSOM
$web = Get-SPWeb http://demo2010a:20905
$pages = "http://demo2010a:20905/Pages/TvAndRadioAlerts.aspx","http://demo2010a:20905/Pages/Systems.aspx"
$pages | ForEach-Object {
$item = $web.GetListItem($_)
if ($item.File.CheckOutType -ne "None")
{
$item.File.CheckIn("Automatically checked in by Powershell", "MajorCheckIn");
}
if ($item.Versions[0].Level -ne "Published")
{
$item.File.Publish("Automatically published by Powershell");
}
if ($item.ModerationInformation.Status -ne "Approved")
{
$item.File.Approve("Automatically approved by by Powershell");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment