Thursday, September 26, 2013

Powershell Script to Check Multiple Files In in a Version Enabled Library

Versioning is a very useful feature on document libraries but sometimes when you bulk load a bunch a files you might have a hard time checking it in. In my case I couldn’t disable versioning to upload the files, so I tweaked a script I had to check the files in. If you are in the same situation you may find it a time saver script.
Follow the Powershell script:
$web = Get-SPWeb -Identity “http://myweb/sites/test“
function ProcessFolder {
$folder = $web.GetFolder($folderUrl)
foreach ($file in $folder.Files) {
write-output $file.url
write-output $file.CheckOutStatus
if ($file.CheckOutStatus -ne “None”) {
$file.CheckIn(“”, [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn)
write-output “Checked file in”
foreach ($subfolder in $folder.SubFolders)
write-output $subfolder.Url

No comments:

Post a Comment