Add ManagedBy settings in Powershell

I just created 300 new distribution lists on our mixed Exchange environment. These new DLs, all needed a manager assigned to them.

The script below requires/uses cmdlets from the Microsoft Exchange 2007 Shell. For one that doesn't need them, check out Brandon's blog.

$mgr = "Eric Woodford"
$mgrMbx = Get-Mailbox -Identity $mgr
$mgrAEA = $mgrMbx.LinkedMasterAccount

$GroupDN = Get-DistributionGroup -Identity "All Users Distribution Group"

#Use this to assign it to the Associated External Account
$GroupDN | Add-ADPermission -User $mgrAEA -AccessRights WriteProperty

#Or this to assign to the local mailbox
#$GroupDN | Add-ADPermission -User $mgrmbx -AccessRights WriteProperty

$GroupDN | Set-Group -ManagedBy $mgr

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <blockquote> <center> <hr> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal6>, <html>, <java>, <javascript>, <php>, <posh>.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.