top of page
Search

Email Delegate Party

  • ToddimusPrime
  • Aug 13, 2021
  • 1 min read

Do you have an account within your Exchange Online that needs to be a delegate on every single mailbox? Perhaps it's a journaling/archiving service or something. It's always fun when somehow the process for provisioning new mailboxes isn't followed fully and you end up having no idea which mailboxes do or don't have the account in question as a delegate... Feat not! This PowerShell script will give you a list of every account that doesn't currently have the delegate set. Just add the delegate email address in line 1, and away it goes. I'm sure there's a better/more efficient way to do this, but hey it works. Also, don't worry about the $flooble and $doodad variables. I wasn't feeling very creative. Feel free to edit line 11 if you want it to do something to accounts that are already happy.


$delegate = "<email address to see who doesn't have it as a delegate>"
$mailboxes = get-mailbox #set $mailboxes to a list of every mailbox in the organization

foreach ($mailbox in $mailboxes) #loop through every mailbox in the organization
{
    $flooble = $mailbox.alias #convert to a single string instead of the whole mailbox object so the next line works
    $doodad = Get-MailboxPermission -identity $flooble #gets the permissions of the mailbox

    if ($doodad.user -contains $delegate) #if $delegate is found in the permissions list of the mailbox
    {
        #Write-Host "already there"
    }
    else
    {
        Write-Host $mailbox.identity #these accounts do not have $delegate as a delegate
    }
}

Comments


©2021 by ToddimusPrime

bottom of page