0

I'm creating sites, subsites and lists via PS. And I need to "enable" the version/size columns, in lists I created.

I don't want to create them because they already exist. In graphical mode, I just have to check the column's box I want, then the column appear in lists.

But in PS, I can't find a way to do it.

I find things like this : (sources)

  $myCustomList = $myTestWeb.Lists[$ListName]

    #Add columns

    $spFieldType = [Microsoft.SharePoint.SPFieldType]::Text 

    $myCustomList.Fields.Add("TextField",$spFieldType,$false)

But it does not work. If someone can rescue me :)

Thanks in advance,

Nico.

P.S : I apologize for my bad english :(

  • I can't add "Hello" at the beginning of my post... It dissapears automatically =/ – Nico Aug 6 '13 at 10:32
  • 1
    For good reasons ;) You should add the fields to the default view, not the list itself (since as you say, they are already on the list) google.com/search?q=viewfields.add+powershell – Robert Lindgren Aug 6 '13 at 11:29
  • I'm not sure I understand exactly what you mean. The default view is an object (or attributes) of the list itself ? I do $list=$web.Lists["NameofMyList"], then I have to do something with the $list, Am I right ? I'm gonna search deeper with what you gave to me :) Thanks for you reply – Nico Aug 6 '13 at 11:43
  • 1
    A list has one or more Views that renders and displays list items from the list. you find them under $list.Views . From what I get from your question, you want to show some fields that are already on the list (but not visible)? If so, then you have to add the fields to the Views you are using – Robert Lindgren Aug 6 '13 at 11:48
  • 1
    You also need to call view.Update() on the view. Check the examples on google – Robert Lindgren Aug 6 '13 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.