-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCheckInDocs.ps1
More file actions
30 lines (28 loc) · 941 Bytes
/
CheckInDocs.ps1
File metadata and controls
30 lines (28 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[CmdletBinding()]
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$false, HelpMessage='URL of site collection')]
[string]$url
)
# Check in documents with no published version.
function CheckInDocs ($url) {
$site = Get-SPSite $url
# Loop all webs
foreach($web in $site.AllWebs) {
# Only Document Libraries
foreach($list in $web.GetListsOfType([Microsoft.SharePoint.SPBaseType]::DocumentLibrary)) {
# Take over checkout
$list.CheckedOutFiles | % { $_.TakeOverCheckOut() }
# Force check in
$list.CheckedOutFiles | % {
$item = $list.GetItemById($_.ListItemId)
$item.File.CheckIn("File checked in by administrator")
Write-Host $item.File.ServerRelativeUrl -NoNewline; Write-Host " Checked in " -ForegroundColor Green
}
}
# Clean memory
$web.dispose();
}
$site.dispose();
}
# Invoke
CheckInDocs $url