1

I've the following code to retrieve list items and select properties:

$list = $web.Lists["MyCustomList"]
$listItems = $list.GetItems()
$items = $listItems | select "MyCustomFieldName"

This does not work tho (I've tried with ex. 'Title' and it works), how could I retrieve the custom field? If I do the following, it gives me the value:

$listItems[0]["MyCustomFieldName"]
1
  • 1
    Do you see the custom column when you use "Select * "? Mar 14, 2018 at 17:49

1 Answer 1

0

Don't ask me to explain how this works, but try:

$items = $listItems | select @{ Label="MyCustomFieldName";Expression={$_["MyCustomFieldName"]}}

or an alternate, if you don't mind looping instead of using select:

 $items = $listItems | % { $_["MyCustomFieldName"] }

Credit: https://stackoverflow.com/a/27373810/1452528

0

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.