locked
Get the check out file based on users Name RRS feed

  • Question

  • Hi,

     

    My environment is SharePoint 2007. I had write a Power shell script to get the file names and checked out by username and their email id.  I am successfully able to get these details.

    Now I want to find out the check out file based on user name. 

    eg:

    There is a web app called http://moss having about 80 site collection.

    There is a user called UserA. he is a contributor to 10 site collection.

    I want to know how many documents are checked out to these particular UserA only.

     

    The requirement is to find out the documents Checked Out to UserA as this user left the company.

     

    Thanks in Advance.

     


    Aniket
    Tuesday, January 3, 2012 5:16 AM

Answers

  • I had write down the script to get the checkout file by user name here is the script :
            function Get-CheckedOutFiles() {
            [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
            $userlogin = "domain\username";
            $site = New-Object Microsoft.SharePoint.SPSite("http://moss/sites/teams")
              
                    
                    foreach ($web in $site.AllWebs) 
                    
                     {
                        Write-Host -foregroundcolor red "Processing Web: $($web.Url)..."
                        
                           foreach ($list in ( $web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]}) ) {  
                                
                            Write-Host -foregroundcolor green "Processing List: $($list.RootFolder.ServerRelativeUrl)..."
                         
                         foreach ($item in $list.CheckedOutFiles) {
                            if ($item.CheckedOutBy.LoginName -eq $userLogin) {
                            Write-Host -foregroundcolor Blue $web.Site.MakeFullUrl(“$($web.ServerRelativeUrl.TrimEnd(‘/’))/$($item.Url)”)
                            
                            Write-Host -foregroundcolor DarkMagenta $item.File.CheckedOutBy.LoginName
                            Write-Host -foregroundcolor DarkCyan $item.File.CheckedOutBy.Name
                           
                            
                            }
                        }
                        foreach ($item in $list.Items) {
                            if ($item.File.CheckOutStatus -ne "None" -and $item.File.CheckedOutBy.LoginName -eq $userLogin) {
                                Write-Host -foregroundcolor Blue $web.Site.MakeFullUrl(“$($web.ServerRelativeUrl.TrimEnd(‘/’))/$($item.Url)”)
                                Write-Host -foregroundcolor DarkMagenta $item.File.CheckedOutBy.LoginName
                                Write-Host -foregroundcolor DarkCyan $item.File.CheckedOutBy.Name
                                
                            }
                        }
                                   
                    }
                   
                  $web.Dispose()  
                          
              }
            }
            Get-CheckedOutFiles 
    This script give the checkout file by user when it was first upload and checked out to user which is seen only through Manage Checkout Files option under Document library settings.Such files dont show username when it pops up in power shell results.
    and it shows also the check out file by user during editing process.
    I am not sure how much it will effect the performance as i had just run it on dev but it works well for my scenario.
    I want to extend it to spit the result into excel and send it to the user.
    Any powershell guru to help me out with that.
    Thanks

    Aniket
    • Marked as answer by Aniket SPoint Wednesday, January 11, 2012 6:22 AM
    Wednesday, January 11, 2012 6:21 AM

All replies

  • Hi,

     

    You can logon using this account and go to Site Actions>View Reports>checked out to me to view all documents and pages checked out to current user in this sites and subsites.

     

    You can also add a new Managed Property which maps to the list meta data field holding the name of the user the item has been checked out to. Then perform a full crawl and make some changes to Advanced Search web part. After these, you can search for documents that have been checked out to a specific user using standard SharePoint search indexing and features. For detailed steps, please check this:

     

    http://tips4sharepoint.blogspot.com/2009/04/checked-out-to-me-report-across.html

     

    Thanks.


    Pengyu Zhao

    TechNet Community Support

    Thursday, January 5, 2012 7:34 AM
  • With the answer you had given with that i can only get the users who had checked out the item which was not uploaded first time.

    But if the user had uploaded the 100 files in 1 go and had never been checked in then your solution doesn't work.

     

    For above tasks i already had written the powershell script which will bring all the checkout files.

    But i want the checked out file for the specific user (who left the company) not for all the users. so i can re run the script and automatically check in those files instead of going to each site collection.

     

     


    Aniket
    Thursday, January 5, 2012 10:36 PM
  • Hi, use SPQuery to retreive the list items which are checked out by current user query against "CheckoutUser" field
    Anil
    Tuesday, January 10, 2012 8:23 PM
  • The current user had left the company?

    i dont know how it will work by  CheckoutUser . can you show me how.

     

    thanks


    Aniket
    Tuesday, January 10, 2012 10:40 PM
  • I had write down the script to get the checkout file by user name here is the script :
            function Get-CheckedOutFiles() {
            [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
            $userlogin = "domain\username";
            $site = New-Object Microsoft.SharePoint.SPSite("http://moss/sites/teams")
              
                    
                    foreach ($web in $site.AllWebs) 
                    
                     {
                        Write-Host -foregroundcolor red "Processing Web: $($web.Url)..."
                        
                           foreach ($list in ( $web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]}) ) {  
                                
                            Write-Host -foregroundcolor green "Processing List: $($list.RootFolder.ServerRelativeUrl)..."
                         
                         foreach ($item in $list.CheckedOutFiles) {
                            if ($item.CheckedOutBy.LoginName -eq $userLogin) {
                            Write-Host -foregroundcolor Blue $web.Site.MakeFullUrl(“$($web.ServerRelativeUrl.TrimEnd(‘/’))/$($item.Url)”)
                            
                            Write-Host -foregroundcolor DarkMagenta $item.File.CheckedOutBy.LoginName
                            Write-Host -foregroundcolor DarkCyan $item.File.CheckedOutBy.Name
                           
                            
                            }
                        }
                        foreach ($item in $list.Items) {
                            if ($item.File.CheckOutStatus -ne "None" -and $item.File.CheckedOutBy.LoginName -eq $userLogin) {
                                Write-Host -foregroundcolor Blue $web.Site.MakeFullUrl(“$($web.ServerRelativeUrl.TrimEnd(‘/’))/$($item.Url)”)
                                Write-Host -foregroundcolor DarkMagenta $item.File.CheckedOutBy.LoginName
                                Write-Host -foregroundcolor DarkCyan $item.File.CheckedOutBy.Name
                                
                            }
                        }
                                   
                    }
                   
                  $web.Dispose()  
                          
              }
            }
            Get-CheckedOutFiles 
    This script give the checkout file by user when it was first upload and checked out to user which is seen only through Manage Checkout Files option under Document library settings.Such files dont show username when it pops up in power shell results.
    and it shows also the check out file by user during editing process.
    I am not sure how much it will effect the performance as i had just run it on dev but it works well for my scenario.
    I want to extend it to spit the result into excel and send it to the user.
    Any powershell guru to help me out with that.
    Thanks

    Aniket
    • Marked as answer by Aniket SPoint Wednesday, January 11, 2012 6:22 AM
    Wednesday, January 11, 2012 6:21 AM