Garry Shape
asked on
Get names of users from Get-MailboxPermission
When I get a list of users or groups who have mailbox access to another user or group, how can I turn that list of users from domain\username into their display names?
I'm trying this from the Exchange powershell after importing ActiveDirectory module:
But I get this in return:
I'm trying this from the Exchange powershell after importing ActiveDirectory module:
Get-MailboxPermission -identity JSmith| select user | foreach ($user in $users) {Get-ADUser $user.Name}
But I get this in return:
Unexpected token 'in' in expression or statement.
+ Get-MailboxPermission -identity JSmith| select user | foreach ($user in <<<< $users) {Get-ADUser $user}
+ CategoryInfo : ParserError: (in:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$Users = Get-MailboxPermission -identity JSmith
foreach($user in $users){
Get-ADUser $User.user | Select Name}
However, this command would not work for group entries as its get-ADGroup for groups.
Instead of using Get-ADuser and Get-ADgroup you could use Get-ADObject as common command for both user and groups. But i am not sure if Get-ADObject command will accept UPN as input identity