4

I'm trying to undo a checkout with PowerShell but the function name doesn't seem to be recognized. Here is the code that I used.

$dList = [Microsoft.Sharepoint.SPDocumentLibrary]$list
            $items = $dList.Items
            $files = $dList.CheckedOutFiles
            foreach($file in $files)
            {

                $wuse = $file.DirName.Substring($web.ServerRelativeUrl.Length)
                Write ($web.Url+ "`t" + $wuse+"`/" + $file.LeafName +  "`t" + $file.CheckedOutBy.Name + "`t" + $file.TimeLastModified.ToString()+"`t" + "No Checked In Version" )

                $file.UndoCheckOut;


            }
            foreach($item in $items)
            {
                if ($item["Checked Out To"] -ne $null)
                {
                    $splitStrings = $item["Checked Out To"].ToString().Split('#')

                    Write ($web.Url+ "`t" + $item.Url + "`t" + $splitStrings[1].ToString() + "`t" + $item["Modified"].ToString() +"`t" + $item["Version"].ToString())

                    $item.UndoCheckOut;
                }
            }

Here is how I enable the powershell snap-in

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
1
  • Could u share the error msg which u are getting. Commented Nov 11, 2013 at 17:53

1 Answer 1

7

I believe

$file.UndoCheckOut;

Should in fact be...

$file.UndoCheckOut()

The same goes for items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.