0

In Powershell i get all checked out file from a library with

foreach($f in $lib.CheckedOutFiles){ //I tried to retrieve item with $item = $lib.GetItemById($f.ListItemID)//exception item not retrieve } 

How can i checkin spcheckedoutfile?

SOLUTION

I finally found a solution. For having item i have to do a TakeOverCheckOut before and after i can have item and file to checkin

foreach ($item in $lib.CheckedOutFiles) { write-Host $item.ListitemId $item.TakeOverCheckOut()//to retrieve item i have to do this before $doc = $lib.getItemById($item.ListitemId) $itemFile = $doc.File if($itemFile -ne $null){ $itemFile.CheckIn("Checked In By Administrator for achive") write-Host " Checked In" -ForeGroundColor Green } } 

1 Answer 1

0

To check-in all files within a specific library, try this

$spWeb = Get-SPWeb http://yoursite/ $splist = $spWeb.Lists |? {$_.Title -eq "libname"} foreach ($item in $splist.Items) { if( $item.File.CheckOutStatus -ne "None" ) { $item.File.CheckIn("Checkedin") } } $spWeb.Dispose() 

Check also how to checkin all checked out files via powershell?

4
  • Thanks but with this method you don't have files that has not yet checked in Commented Oct 9, 2016 at 12:24
  • I am sorry , but what I understand from you , you need to check in all checked out files , should you elaborate more what you need specifically , to can help you :) ? Commented Oct 9, 2016 at 13:17
  • 2
    Yes i use your solution for file already checked in in library but files that are not yet in library is not in items of library. You have to use .CheckedOutFiles. Commented Oct 9, 2016 at 19:47
  • Great job, thanks for this info :) , forgive me I think I didn't understand your question correctly at the first :) , So I answered based on this line in your quest I get all checked out file from a library to check in Commented Oct 9, 2016 at 19:56

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.