What is the SharePoint cmdlet for lists, calendars, etc. for a SharePoint 2013 site using PowerShell

I have used the cmdlet Get-DocInventory  within a PowerShell script which gave me every single document on my site which was great.

However, I need everything above this level to be listed such as Calendars, Lists, Root Folders, etc.  What is the cmdlet to get this data and how do I within the powershell script indicate to export it to a csv file.
upobDaPlayaAsked:
Who is Participating?
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.

 
colly92002Commented:
In SharePoint, you can consider everything to be a list, the difference between a ist of data and a calendar for example is simply the view used to present the data.  

Therefore you can use a CAML query in Powershell to extract everything you need.  

Here is an example of a generic powershell script to read the title of every item in a list, just extend it to cover whatever you want it to show:
$web = Get-SPWeb http://<site>
$list = $web.Lists["<listname>"]

$spQuery = New-Object Microsoft.SharePoint.SPQuery
$spQuery.ViewAttributes = "Scope='Recursive'";
$spQuery.RowLimit = 2000
$caml = '<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>' 
$spQuery.Query = $caml 

do
{
    $listItems = $list.GetItems($spQuery)
    $spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
    foreach($item in $listItems)
    {
        Write-Host $item.Title
    }
}
while ($spQuery.ListItemCollectionPosition -ne $null)

Open in new window


Here is a nice reference (2010 but the same):
http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/22/use-powershell-to-manage-lists-views-and-items-in-sharepoint.aspx
0

Experts Exchange Solution brought to you by ConnectWise

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
 
upobDaPlayaAuthor Commented:
Thanks Colly92002 this is great and a a good reference - 2 quick follow-ups

1-How would I get the data out to a csv file ?
2-I understand you explanation about a list, it thus appears I would have everything by running the above so then you threw me for a curve when you mentioned "just extend it to cover whatever you want it to show:.."  what would be an example of me extending the above query ?

Thanks
0
 
colly92002Commented:
1 - Powershell has a handy Export-CSV cmdlet for this - example here: http://porchcode.blogspot.co.uk/2013/04/exporting-sharepoint-list-items-to-csv.html

2 - The example I gave you is very basic, it will export a single list, and only the "Title" column.  All I am trying to say is that you could add more code to export for example more columns from your list, or export more than a single list (cut'n'paste code block with a different list name).   If you wanted to, you add code to iterate through all the lists in your site and iterate through all the columns in the lists and export them all :)  Powershell is incredibly powerful, one you are started with it there is virtually no limit to what you can do.

Also, Windows comes with a really good Powershell dev envrionmnt, but it's hidden away for some reason.  Have a look at this: https://technet.microsoft.com/en-us/library/dd315244.aspx
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
upobDaPlayaAuthor Commented:
Thanks Colly92002 to add more columns is there a handy reference where I would find the additional columns.  I assume I would just add below the line

{
        Write-Host $item.Title
        Write-Host $item.Col2 eg. Last Update
    }
}
while ($spQuery.ListItemCollectionPosition -ne $null)
$expath = $outPath + '\' + $list.Title + '.csv'
  $exportlist | Export-Csv -path $expath #$oPath

thx !
0
 
colly92002Commented:
Yes that is correct, just add more lines like:
Write-Host $item.Title
(I have a feeling the syntax is slightly diffferent for non-built in columns, see here for other examples of how to do this: http://www.thorntontechnical.com/tech/sharepoint/quick-tip-sharepoint-powershell-get-items-in-a-list-based-on-custom-columns-and-other-hints#.VRpxwuEvzks)

Here is an example of how to iterate through all the columns:
http://sharepoint-community.net/profiles/blogs/sharepoint-get-spfield-details-for-sharepoint-lists-using

Powershell can be infuriating as the syntax is very specific, and there are so many ways to do the same thing!  However it is very powerful so worth learning.
0
 
upobDaPlayaAuthor Commented:
Thx !  I want to spend one more day reviewing and then I will post the grade. this is great thanks again
0
 
upobDaPlayaAuthor Commented:
Great sample and more importantly a great resource to benefit my learning of PowerShell
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.