One of my client requested for validating the list fields. The list is deployed as part of custom solutions. There is no big challenge doing it by inserting validation formula. However I took a quick look of PowerShell property to achieve the same.
List Available in SharePoint 2010
Where Title is set to 255 and Age is a Number Data Type accepts range between 18 and 30. We can do this in GUI as well. Let’s see the code in PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $web = Get-SPWeb -Identity 'http://host.com/subsite' $List = $web.Lists["ListName"] $Field = $List.Fields['Age'] $field.ValidationFormula = "=AND([Multiline]>18,[Multiline]<30)" $field.ValidationMessage = "The value of this field is between 18 and 30" $field.Update()