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
$stringColl.AddRange($choiceFieldChoices)
# 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
$web.Update()
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.