0

Is it possible, to get a multiple string-values from an AD User property?

I have an property that contains various departments and want to get all departments, in list format.

Can I loop through this Array?

$bvsDepartments = Get-ADUser USER -Properties bvsDepartments | select bvsdepartments

output: 
bvsdepartments
--------------
{Value1, Value2, Value3,...}
3
  • 2
    What do you mean by 'list format'? Array? String? Updating | select -ExpandProperty bvsdepartments will give you an array of values.. Commented Jun 7, 2018 at 10:25
  • $bvsDepartments.bvsDepartments[0], $bvsDepartments.bvsDepartments[1], $bvsDepartments.bvsDepartments[2] and so on... Commented Jun 7, 2018 at 10:26
  • Thanks @JamesC. this is working fine! Commented Jun 7, 2018 at 10:49

1 Answer 1

1

If you update your select with ExpandProperty this will give you an array of just the values rather than the property as an object.

$bvsDepartments = Get-ADUser USER -Properties bvsDepartments |
    select -ExpandProperty bvsdepartments
Sign up to request clarification or add additional context in comments.

Comments

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.