Help with Get-ADUser Output!?!?!

In short I have made a little GUI tool to create Super accounts in our domains. This tool will get the attributes from the user's regular account by making them into a variable and using that variable during the new-aduser cmd to set the attribute. I am having trouble with a command, the command gets what I need but not in the right format. Here is what I am doing.

When the button is clicked to initiate the cmd it will first go through setting variables and one of the examples I am having trouble with is:

$StAddress = Get-ADUser $textfield1.text -Properties * | Select-Object Streetaddress

This returns:



255 Park Ave


I can even use:

$StAddress = Get-ADUser $textfield1.text -Properties * | Select-Object Streetaddress  | FT -HideTableHeaders

And this produces:

255 Park Ave


When I am setting the Street address it will set but it will be this

@{Streetaddress=2555 Park Ave}

instead of 255 Park Ave


When I am doing any of the properties from the Get-member cmd I can just use dotted notation and I don't have this problem i.e. (get-aduser textfield.text).Givenname but that wont work with any properties outside the Get-aduser <User> | GM cmd


Any Ideas??


  • You were on the right track by using the Select-Object cmdlet, the parameter you are looking for is -ExpandProperty, this only outputs the value in the property rather than the key-value pair. Here is what this looks like in code:

    $StAddress = Get-ADUser $textfield1.text -Properties * | Select-Object -ExpandProperty Streetaddress

    Alternatively you could encapsulate the entire command in Parentheses and select the property you require:

    $StAddress = (Get-ADUser $textfield1.text -Properties *).Streetaddress

    Does that answer your question?

  • I appreciate this thread is from 7 years ago but created an account just to upvote this, was attempting to create an alias using get-aduser -properties ...... but when attempting to input the alias into another function alias was showing result [email protected]=xxxx adding in -ExpandProperty resolved, Thank you!

Reply Children
No Data