Skip to main content

Cloud

Get SharePoint List Definitions with PowerShell

I have often found that I need to quickly get at the fields defined on a SharePoint list. PowerShell provides an easy mechanism for getting at this and any other data exposed by the SharePoint object model.

Here are the steps to follow to get at the field definitions on a list called "test" in the root web of a site called "http://sharepoint.local".

1) Load the Microsoft.SharePoint assembly into your PowerShell session so that you can utilize the classes defined within.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Sharepoint")

2) Create an instance of SPSite

$site = new-object Microsoft.SharePoint.SPSite("http://sharepoint.local")

Note: You need to use the fully qualified class name here.

3) Get the list that you want to work with

$list = $site.RootWeb.Lists["test"]

4) Display the fields using the format-table cmdlet (aliased to "ft") and specify the properties you want to display

$list.Fields | ft title, internalname, type

The result should look something like this.

Using this same approach, you can quickly and easily get at all kinds of useful data that is available via the SharePoint object model.

p.s. Don’t forget to Dispose() the SPSite when you are done with it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

PointBridge Blogs

More from this Author

Follow Us