1

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.

1 Answer 1

1

This worked for me if I understand what you want:

Get-ADUser -Identity SAMAccountName -Properties EmailAddress,Manager | %{(Get-AdUser $_.Manager -Properties EmailAddress).EmailAddress} 
Sign up to request clarification or add additional context in comments.

1 Comment

Great ForEach-Object, instead of a Select-Object is where its at! Thanks again.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.