Retrieve a List of All Items Checked Out in a Site using Powershell


Hi there!

This is a scripts to list files which are currently checked out on a site collection. Some times users check files out and forget to check them back in. It was based on a script found at http://www.thorntontechnical.com/tech/powershell-tech/powershell-tip-find-all-checked-out-files.

$webAppURL = "http://yourwebapplication.com" 

function ReportCheckedOutItems() {
	$webapp = Get-SPWebApplication $webAppURL

	foreach ($site in $webapp.Sites) 
	{
		write-host "Site Collection: $($site.Url)"
		$allwebs = $site.allwebs
		foreach($web in $allwebs)
		{
			$count = 0
			write-host "--Site: $($web.Url)"
			foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
				Write-Host "-----List: $($list.RootFolder.ServerRelativeUrl)..."
				foreach ($item in $list.CheckedOutFiles) 
				{
					if (!$item.Url.EndsWith(".aspx")) 
					{ 
						continue 
					}
					write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
					$count++
				}
				foreach ($item in $list.Items) 
				{
					if ($item.File.CheckOutStatus -ne "None") 
					{
						if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) 
						{ 
							continue 
						}
						write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
						$count++
					}
				}
			}
			if ($count -gt 0)
			{
				write-host "Found $count checked out files for site $web" -ForeGroundColor Red
			}
		}
	}
}

ReportCheckedOutItems

 

You can download the script file here

I hope it is useful for you as it is for me.

 

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: