none
Need to show mailbox name against each iteration of foreach being run against mailboxes - Powershell

    Question

  • Hi all, I'm pretty new to this so apologies in advance if I embarrass myself! I'm trying to get a list of all room mailboxes and whether a service account has Impersonation Rights to it or not. We have a Service Account that has Application Impersonation rights so I'm running the following;

    $Rooms = get-mailbox | where {$_.recipienttypedetails -eq "RoomMailbox"}

    Foreach ($Room in $Rooms) 

    {

    Get-ManagementRoleAssignment -GetEffectiveUsers | Where {$_.RoleAssigneeName -eq "RC SRV"}

    }

    But all I get is;

    Name                           Role              RoleAssigneeName  RoleAssigneeType  AssignmentMethod  EffectiveUserNam
                                                                                                           e
    ----                           ----              ----------------  ----------------  ----------------  ----------------
    impersonationassignmentname    ApplicationImp... RC SRV            User              Direct            RC SRV
    impersonationassignmentname    ApplicationImp... RC SRV            User              Direct            RC SRV
    impersonationassignmentname    ApplicationImp... RC SRV            User              Direct            RC SRV 

    etc, a line for every Resource Mailbox we've got.

    I've tried (among other things) adding 

    $RoomName = $Rooms.Alias
    write-output $RoomName

    But it just lists every room against each output. I'm struggling and would really appreciate some help guys, my own investigating isn't turning much up, mainly because I don't think I know enough about scripting to know what to look for!

    Thanks in advance....


    Friday, December 7, 2018 3:09 PM