Powershell Script to Check Multiple Files In


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://%5BSERVER NAME]/[SPWEB]”

$folderURL = “[DOCUMENT LIBRARY]/[FOLDER]”

function ProcessFolder {
param($folderUrl)
$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
ProcessFolder($subfolder.Url)
}
}

ProcessFolder($folderURL)
 

See you,

Amadeu.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: