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 * "? Commented 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.