am having a requirement to create a power shell script which set the column order from mandatory fiels to optional fields in the document library, when i try to upload a document.

if i elaborate, i am uploading a doc to the doc lib. which has the below columns:

columnA - [choice field - mandatory ]

columnB - [lookup field - mandatory ]

columnC - [single line of text - optional ]

columnD - [choice field - optional ]

columnE - [choice field - mandatory ]

now when the end user uploads a document in my doc lib, i would like to see the mandatory columns takes up the top order and then optional fields.






so, is there any script, through which i can set the mandatory columns which will be coming in top and the optional fields as next order

  • Are these fields in a content type? Feb 25, 2015 at 8:30
  • Thanks for your reply Nadeem. Yes, These columns are coming from content type.Also i tried to write few lines of coe. but it did not work.
    – samolpp2
    Feb 25, 2015 at 8:54
  • $list = $web.Lists[$abc] $list.Title $result=New-Object system.Collections.Generic.List[Microsoft.SharePoint.SPContentType] $ContentType="Memo"{$ctype = $list.contenttypes[$ContentType] $newFieldOrderfromxml = "column3, column1,column4,column7,column6.column2" $newfieldorder = $newFieldOrderfromxml.Split(',') $ctype.FieldLinks.Reorder($newFieldOrder) $ctype.update() $rresult.Add($ctype) } $list.RootFolder.UniqueContentTypeOrder = $result $list.RootFolder.Update()
    – samolpp2
    Feb 25, 2015 at 9:09

2 Answers 2


This is a sample PowerShell Code:

$web = Get-SPWeb http://aissp2013/sites/TestSite
$list = $web.Lists["MyList"]
$contentType = $list.ContentTypes | where {$_.Name –eq "MyTestCT"}
$ctArray = "Title","ColumnA","ColumnB","ColumnD","ColumnC"

I hope Nadeem's solution will work for you. In case you face some issues with it you can do the same using UI.

  1. Go to Library Settings
  2. Click your content type under "Content Types"
  3. Click the "Column order"

Change the columns order as you want.


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.