Link to home
Create AccountLog in
Avatar of upobDaPlaya
upobDaPlaya

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of colly92002
colly92002
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of upobDaPlaya
upobDaPlaya

ASKER

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
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
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 !
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.
Thx !  I want to spend one more day reviewing and then I will post the grade. this is great thanks again
Great sample and more importantly a great resource to benefit my learning of PowerShell