How to Format output into variable

Hi,

I would like to convert a Display Name in to a UserPrincipalName

When i run de following cmd in PS:

$UPN = Get-ADUser -Filter "CN -eq '$DisplayName'" | Select UserPrincipalName

The Value of $UPN = @{UserPrincipalName=example@mail.nl}

How do i get only example@mail.nl into $UPN

Thnx

You only want that property, so you just need to set the variable equal to that property. This should do the trick.

$UPN = (Get-ADUser -Filter "CN -eq '$DisplayName'").UserPrincipalName

Thanx a lot Darwin, that did indeed the trick…