Wednesday 1 January 2014

MultiChoice CheckBox field using PowerShell


Create SPField Multichoice checkbox field using Powershell


  # Read the Site Url from User

 $url = Read-host " Enter Name of the Site to Add Document Library"


   # get Website name

$OpenWeb = Get-SPWeb $url -ErrorVariable err -ErrorAction SilentlyContinue -AssignmentCollection $assignmentCollection



       # Get the Document Library Name              

$lib=$OpenWeb.Lists["DocumentLibraryName"]
       # Create and xml field element to add multichoice values

$fldXml = "<Field Type='MultiChoice' DisplayName='Document Status' Name='DocumentStatus' >
                       
                        <CHOICES>
                            <CHOICE>Review Required</CHOICE>
                            <CHOICE>Review in Progress</CHOICE>
                            <CHOICE>Review Completed</CHOICE>
                        </CHOICES>
           </Field>"

$lib.Fields.AddFieldAsXml($fldXml,$true,[Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)

$lib.Update()





that's set ........

OutPut:



No comments:

Post a Comment