Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have following powershell:

    $webUrl = 'http://demo2010a:90/sites/Contracts'
    $web = Get-SPWeb $webUrl;
    $lists = $web.GetListsOfType($SPBaseTypeDocumentLibrary);
    foreach ($list in $lists)
    {
    $folders = $list.Folders
    foreach ($spFolder in $folders)
    {   

        #$item = $spFolder.Item
        $item = [Microsoft.SharePoint.SPListItem]::$spFolder.Item
        if ($item -eq $null)
        {
            Write-Host "Null found"
        }
        else
        {
        }   
     }
     }

     $web.Dispose()

The problem is I can't seem to get SPListItem from SPFolder

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You are getting it. $list.Folders is a collection of SPListItems so $spFolder is already a SPListItem. Just $item = $spFolder is enough.

SPListItem.Item is used to get or set the value that is contained by the specified field.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.