How to Create a Choice Site Column in a SharePoint Site with PowerShell
To get articles like this free in your inbox, subscribe to our newsletter.

This time I am sharing a small script that allows to create a choice site column through PowerShell. As you can see, the way to create this type of column is the same as if you use the SharePoint server API in a Console Application program in Visual Studio. You can download the script from the following link: How to create a Choice Site Column in a SharePoint Site!
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }
$host.Runspace.ThreadOptions = “ReuseThread”
#Definition of the function that creates a New Site Column in a SharePoint Site.
function Create-SiteColumn
{
param ($sSiteCollectionUrl,$sFieldDisplayName, $sFieldInternalName, $sFieldType)
try
{
$spSite = Get-SPSite –Identity $sSiteCollectionUrl
$spWeb = $spSite.OpenWeb()
#We check the field type is not null
if($sFieldType -ne ”)
{
write–Host “Adding the field $sFieldDisplayName to the Site” -foregroundcolor blue
$spWeb.Fields.Add($sFieldInternalName,$sFieldType,$false)
$spChoiceField=$spWeb.Fields.GetField($sFieldInternalName)
$spChoiceField.Group=”MVP Columns”
$spChoiceField.Choices.Add(“Developer”)
$spChoiceField.Choices.Add(“IT Pro”)
$spChoiceField.Choices.Add(“Architect”)
$spChoiceField.Title=$sFieldDisplayName
$spChoiceField.DefaultValue=”Developer”
$spChoiceField.FillInChoice=$true
$spChoiceField.Update()
}
#Disposing SPSite and SPWeb objects
$spWeb.Dispose()
$spSite.Dispose()
}
catch [System.Exception]
{
write–host -f red $_.Exception.ToString()
}
}
#Calling the function
Start-SPAssignment –Global
$sSiteCollectionUrl = “http://winsrv2012:80/sitios/compartimoss”
$sFieldDisplayName=”MVP Type”
$sFieldInternalName=”MVPType”
$sFieldType=”Choice”
Create-SiteColumn -sSiteCollectionUrl $sSiteCollectionUrl -sFieldDisplayName $sFieldDisplayName -sFieldInternalName $sFieldInternalName -sFieldType $sFieldType
Stop-SPAssignment –Global
Remove-PsSnapin Microsoft.SharePoint.PowerShell
Happy CloudSharing!!!
What you should do next…
1. Subscribe to our newsletter:
Subscribe to our newsletter below for the latest news, advice and thought-leadership for software professionals. Or visit our blog to browse our most recent articles.
2. Learn how virtual labs can grow your business:
To learn more about how CloudShare helps software organizations grow revenue, increase efficiency and improve quality, visit our resources page. You’ll be able to browser dozens of valuable white papers, eBooks, webinars, case studies, and brochures.
3. Get a FREE, no obligation demo:
Discover just how easy it is to create your cloud environment—in minutes! One of our friendly virtual labs experts will be happy to:
- Show you the platform in action
- Calculate pricing for your business
- Set you up with a 14-day free trial
- Answer any questions you have
- No pressure or obligation