locked
Need help listing shared mailbox manager names RRS feed

  • Question

  • As I am really bad at writing these things myself, then would like to request help in listing shared mailbox managers alongside with the rest. The script is made by someone else (I really cannot recall from who's topic or board I got it from and I take no credit in it), made some minor modification to it and it does roughly what it is suppose to do. However I just need manager value added to it.

    When I tried in putting either Select or Select-Object with "manager" or the calculation value:

    @{name='ManagerName';expression={(Get-ADUser -Identity $_.manager | Select-Object -ExpandProperty name)}}

    on the second line where the get-mailbox command is I get an error stating that "The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input."

    I guess my issue is that I do not properly understand how to make the calculation value work in this fancy script. As far as I understand manager is the value that is present under AD Atributes, but is not that easily accessible...

    Any help in adding the manager info to this script would be really nice.

    function Get-AllMailboxPermissions { $allMailboxes = Get-Mailbox -OrganizationalUnit '' -ResultSize Unlimited | Select * |Sort-Object Identity if ($allMailboxes.Count -eq 0) { Write-Warning "No mailboxes found." return } foreach ($box in $allMailboxes) { $perms = $box | Get-MailboxPermission | Where-Object { $_.IsInherited -eq $false -and $_.User.ToString() -ne "NT AUTHORITY\SELF" -and $_.User.ToString() -notmatch '^S-1-' } | Sort-Object User foreach ($prm in $perms) { $user = Get-Recipient -Identity $($prm.User.ToString()) -ErrorAction SilentlyContinue # skip inactive (deleted) users if ($user -and $user.DisplayName) { $props = [ordered]@{ "Mailbox" = "$($box.Displayname)" "Email" = "$($box.PrimarySmtpAddress)"

    #"managed" = "$($box.manager)" "User" = $user.DisplayName "AccessRights" = "$($prm.AccessRights -join ', ')" } New-Object PsObject -Property $props } } } } Get-AllMailboxPermissions | Export-Csv -Path '' -NoTypeInformation -Delimiter ';'-Encoding UTF8 -Force


    Can anyone point me to the right direction or explain to me how I can make it work somehow? Luckily if it's not possible or am not worthy enough for your help, I can always do it by hand, luckily there are not over 200 mailboxes.

    Tuesday, October 27, 2020 1:42 PM

All replies

  • Please carefully review the following links to set your expectation for posting in technical forums.

    You will need to first learn Exchange and PowerShell.  After you have learned the basic technology you will then have solved your problem or have a question that can be asked without trying to understand some very old and badly written script.


    \_(ツ)_/

    Tuesday, October 27, 2020 9:21 PM
  • If anyone else needs to use the same type of script then I got mine to work. Might be old, might not be nicest, but does it's work:

    function Get-AllMailboxPermissions {
        $allMailboxes = Get-Mailbox -OrganizationalUnit '' -ResultSize Unlimited | Select * |Sort-Object Identity
    
        if ($allMailboxes.Count -eq 0) {
            Write-Warning "No mailboxes found."
            return
        }
        foreach ($box in $allMailboxes) {
            $perms = $box | Get-MailboxPermission |
                            Where-Object { $_.IsInherited -eq $false -and $_.User.ToString() -ne "NT AUTHORITY\SELF" -and $_.User.ToString() -notmatch '^S-1-' } |
                            Sort-Object User
    
            foreach ($prm in $perms) {
                $user = Get-Recipient -Identity $($prm.User.ToString()) -ErrorAction SilentlyContinue
                $user1 = Get-User $box.Identity
                # skip inactive (deleted) users
                if ($user -and $user.DisplayName) { 
                    $props = [ordered]@{
                        "Mailbox"      = "$($box.Displayname)"
                        "Email"      = "$($box.PrimarySmtpAddress)"
                        "manager" = "$($user1.manager)"
                        "User"         = $user.DisplayName                  
                        "AccessRights" = "$($prm.AccessRights -join ', ')"
                    }
                    New-Object PsObject -Property $props
                }
            }
        }
    }
    Get-AllMailboxPermissions | Export-Csv -Path 'C:\sharedmb.csv' -NoTypeInformation -Delimiter ';'-Encoding UTF8 -Force 
    Somehow got the right search word and found the info I needed in this topic: https://social.technet.microsoft.com/Forums/exchange/en-US/d2c8a324-acd0-44a5-8bf5-292be805414a/how-do-i-get-a-list-of-quotmanagerquot-and-quotdepartmentquot-using-powershell-ad-or?forum=ITCG

    Wednesday, October 28, 2020 8:02 AM
  • Unfortunately your pasted text is broken and mixed with HTML.

    Also your code as posted does nothing useful.  I recommend that you perform more and better tests.


    \_(ツ)_/

    Wednesday, October 28, 2020 9:26 AM
  • As for a mix of HTML and text, for me it looks very normal and nothing is mixed up, even the code is in it's proper "tag".

    If it is nothing useful feel free to delete the topic then as I cannot seem to be able to do so myself. Or move it to elsewhere if it is better fit there.

    But for me, it gets the list of all shared mailboxes in certain OU, prints the name and email of the mailbox as well as members with full access rights and the manager of the shared mailbox into a file. Which is what I personally wanted. Hence I thought I'd leave my code here for someone else to find it, if they need it, as I solved the issue myself.

    Wednesday, October 28, 2020 10:13 AM
  • This is HTML but damaged quotmanagerquot-and-quotdepartmentquot


    \_(ツ)_/

    Wednesday, October 28, 2020 12:03 PM