I am a newbie to PowerShell and I am struggling to modify an output according to the way I want.
The command I run in MS Exchange Shell is this:
Get-Mailbox user1 | Get-ADPermission | ? {($_.ExtendedRights -like "*send-as*") -and -not ($_.User -like "NT AUTHORITY\SELF")} | Select User
The result I get from the above command is:
User
----
AGL\user4
AGL\user5
AGL\groupX
However I would like to obtain the output as:
User
----
user4
user5
groupX
Is it possible to do this?
Thanks heaps in advance.
For this, use a Calculated Property to output the objects with their names only:
Get-Mailbox -Identity user1 |
Get-ADPermission |
Where-Object {($_.ExtendedRights -like "*send-as*") -and ($_.User -ne "NT AUTHORITY\SELF")} |
Select-Object @{Name = 'User'; Expression = {$_.User.Split("\",2)[1]}}