Reputation: 612
I'm trying to get a Users Managers Email from AD with Powershell, so i want to enter UserA and get return [email protected]. so i can reset a user password and have it email the password to the manager specified in AD. so, here is waht i got:
Get-ADUser -Identity SAMAccountName -Properties EmailAddress,Manager | Select-Object { (Get-AdUser $_.Manager -Properties EmailAddress).EmailAddress }
but, its returning it like a table format like this:
(Get-ADUser $_.Manager -Properties EmailAddress).EmailAddres
------------------------------------------------------------
[email protected]
So i cannot use that as a valid email, is there a way to get just the email address. Thnaks for any help.
Upvotes: 1
Views: 9149
Reputation: 37720
This worked for me if I understand what you want:
Get-ADUser -Identity SAMAccountName -Properties EmailAddress,Manager | %{(Get-AdUser $_.Manager -Properties EmailAddress).EmailAddress}
Upvotes: 1