I have written a powershell script to create site columns in the site. I am able to create site columns of type text and number but when I try creating columns of type Choice I get error. The following is my code:

# Build a string array with the choice values separating the values at ","
                $choiceFieldChoices = @($siteColumn.Choices.Split(","))

                # Declare a new empty String collection
                 $stringColl = new-Object System.Collections.Specialized.StringCollection

                # Add the choice fields from array to the string collection

                # Create a new choice field and add it to the web using overload method
                $newSiteColumn = $web.Fields.Add($name,[Microsoft.SharePoint.SPFieldType]::Choice, [System.Convert]::ToBoolean($siteColumn.Required), $false,$false, $stringColl)
                # Update the web

It throws an error in the $web.Fields.Add statement. The error that I get is

Cannot find an overload for "Add" and the argument count: "6".

I have tried a lot but was unable to figure out what is wrong. Please guide.


1 Answer 1


The method SPFieldCollection.Add (String, SPFieldType, Boolean, Boolean, StringCollection) has only five arguments. Whereas, in your code you are passing 6 parameters. Try changing the code to this:

$newSiteColumn = $web.Fields.Add($name,[Microsoft.SharePoint.SPFieldType]::Choice, $false,$false, $stringColl)

Source: https://msdn.microsoft.com/EN-US/library/office/ms477246.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.