SharePoint 2010 Powershell

Do one of you SharePoint 2010 gurus have the Powershell script to check in or undo-checkout of all item's in a picture library.  If you used SP2010 you are probably failure with when you check them in sometimes they still show checked-out.  I know there is a -force way to do it.  I just cannot remember it.  

Goal: Loop through all the documents in a specific Picture Library in a particular site and check them all in (or undo checkout)
LVL 3
Christopher GoreEnterprise Solutions ArchitectAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jamie McAllister MVPSharePoint ConsultantCommented:
Tested this and it works;

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Variables for Site URL and Library Name
$WebURL="http://YourURL/YourSite"
$LibraryName="YourPictureLib"
 
#Get Site and Library
$Web = Get-SPWeb $WebURL
$DocLib = $Web.Lists.TryGetList($LibraryName)
 
#Get all Checked out files
$CheckedOutFiles = $DocLib.Items | Where-Object { $_.File.CheckOutStatus -ne "None"}
 
#Check in All Checked out Files in the library
ForEach($item in $CheckedOutFiles)
    {

        $DocLib.GetItemById($item.Id).file.CheckIn("Checked in by Admin")
        write-host "File:'$($item.Name)' has been checked in!"        
    }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Christopher GoreEnterprise Solutions ArchitectAuthor Commented:
Sorry.  That did not fix it.  They still show up as checked out to me.
0
Kamlesh RaoIT ConsultantCommented:
Hey Christopher, your comment says that the script didn't help.  At the same time you have accepted it as the solution!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.