Adding Custom Field in the Project Sites using Powershell Command

Scenario: You need to update existing project sites with a new/modified list column with a change you are planning to apply to the Project Site Template for new Projects.

Objective: Create a new Custom Text field in the Risk list and deploy it to all existing Project sites.

Solution:

#Specify the PWA url

$sites = Get-SPSite ‘http://demo2010a:5940/PWA’ | Get-SPWeb -Limit All

Foreach($site in $sites)

{

$site.title

#Create the column Text Type with name of Testfield1 in the Risks list

$list = $site.Lists.TryGetList(“Risks”)

# Specify the parameters in the Add method as custom field name, data type and characters

$myField = $list.Fields.Add(“TestField1”, “Text”, 0)

# Create the field in all the Project sites. $list.Fields

[$myField].Update()

Write-host -ForegroundColor green  “Column has been added”

}

Please note you can perform many other activities using PowerShell for which script is available as per below link on the Microsoft Technet gallery:

Bulk Update List Items in the Project Workspace – Click here

Auto Publish All Projects Using Powershell – Click here

Hope this helps you!

Cheers,

Badal

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: