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

My eventual goal is to be able to check on new items added to a Content List but I was trying to figure out if there was a CmdLet that could let me access the Content List in a SharePoint Site. I have a PowerShell script that allows me to get a view into the Content in the site but this is more high level, ideally I would like to be able to get into the sub-sites to look into the content there as well.

Is there something that is already avaiable that might give me access from outside the site, using PowerShell ideally, to be able to get the list of content. This would only need to come out with a list, like a report, so I can get an idea of content in a list or even separate it out according to date.

This is an example of the code I am already using to get an idea of the Content in a Site.

# This uses SPWeb, Lists properties
    $folderList = $siteWeb.Lists[$libraryName]
    $global:totalFolders += $folderList.Folders.Count

    # Review all items within the List that are folders, and get their counts
    # This is using SPWeb, Folders properties, which gets all items as first-level folders
    # This makes $folderItem an SPList object
    #   More on Folders: http://msdn.microsoft.com/en-us/library/ms437326.aspx
    foreach ($folderItem in $folderList.Folders)
    {
        if ( ($folderItem.Folder.ItemCount -gt 0) -and ($folderItem.Name -cnotmatch "False") )
        {
            Write-Host "Folder: " $folderItem.Name "Count: " $folderItem.Folder.ItemCount
            $global:totalCount += $folderItem.Folder.ItemCount
            $gc = Start-SPAssignment
            $site = $gc | Get-SPWeb $url
            $items = Get-SPFilesInFolder $site "Pages" $folderItem.Name
            # $items | fl -Expand Both
            $newItems = $items | where{$_.HasPublishedVersion -eq "True"}
            $global:totalPublished += $newItems.Count
            $invisItems = $items | where{$_.HasPublishedVersion -ne "True"}
            $global:totalUnPublished += $invisItems.Count
            $gc | Stop-SPAssignment
        }

My focus on PowerShell is we do a lot of administration through that now and I would just like to add this as a new part of our PowerShell work that I am more comfortable with rather than a web part - which I am not comfortable with.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

These examples can help you get started -

Phil Childs has a PowerShell that Gets all column values from a SharePoint item.

Kirk Evans' PowerShell example shows how to iterate through large SharePoint lists and its content.

Another example from The Scripting Guy - Getting data from SharePoint List (using PowerShell).

share|improve this answer
    
Thanks for the example links, the information was very useful –  MichaelF Mar 19 '12 at 18:31
    
These came the closest to what I was trying to do, although eventually the decision we reached was to copy the Content Database over to another server then run a SQL Query to pull up the relevant pages. It'd be nice to check this against the Search Web Service but that seems to be a real problem due to our use of FBA and Anonymous Access. –  MichaelF Mar 29 '12 at 11:52

It's pretty simple. Get the web, find your list. The list object has a collection called items.

#Get the SP Web
$web = Get-SPWeb -Identity "http://weburl/sites/procedures"

#Get the List by its Title
$list = $web.Lists | Where-Object { $_.Title -eq "Process Requests" }

$list.Items | ForEach-Object{$_["Title"]}
share|improve this answer

There is no out-of-the box cmdlet for accessing lists. You will need to write your own, or download (and review) one from the internet.

share|improve this answer
    
Is there one on the Internet? I've looked but not come up with anything. –  MichaelF Feb 8 '12 at 17:40

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.