Exchange 2010 implements a change to managing security distribution lists, especially in SP1. When using the Exchange Management Console (EMC) in the RTM version, changes made to membership or ownership of a security distribution list are successful when you are not the owner. This is because a parameter of the Set-DistributionGroup cmdlet is tacitly added that allows someone with the RBAC management role of Security Group Creation and Membership to update the DL. Starting with Exchange 2010 SP1, the console no longer adds this parameter (-BypassSecurityGroupManagerCheck).
The result is that, despite being an administrator (by being in the Organization Management role), if you are not explicitly listed as an owner of a security DL, you will not be able to makes changes to ownership or members via the console…period. This goes against the functionality that has existed in the Exchange console since 1996. And better yet, Microsoft says this is by design. The fact that it worked in RTM is the bug, not the other way around in SP1. I think that is one of the most boneheaded changes made in 2010. The solution is to either add the administrators as explicit owners or have them use the shell and manually add -BypassSecurityGroupManagerCheck.
Both options are impractical. If your help desk manages DLs you can’t just add all members as owners. For one thing, even though Exchange 2010 supports multiple owners, Outlook (even 2010) only displays the first entry. This means end users won’t know who to contact because the listed owners could be one or two “real” owners and all the rest are help desk. The other option, using the shell, isn’t the easiest for anyone that isn’t a dedicated Exchange admin.
My solution for the help desk staff is a PowerShell script that uses Windows forms to provide a GUI that lets you search for a DL, display the ownership, add and remove owners, then apply the changes. It includes username validation so it won’t let you add a user that isn’t mailbox-enabled.
The one place I struggled is connecting to Exchange. The script checks for the Exchange cmdlets being in memory. If they are not, it will connect remotely to a designated server. Because that is done when the form is activated, it causes the painting of the fields and labels to be delayed until the connection is complete. I tried to find a way to wait until the painting is complete before connecting, but you can’t detect that when the fields are drawn by Windows directly and not the application.
The code is listed here, but you can also download a zip file of it:
Change-DLOwner.zip (3.3 KiB)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
#Change ownership of Exchange 2010 SP1 distribution list #Author: Scott Bueffel, http://www.flobee.net #v1.0 1/6/10 $connectToServer = 'ServerName' #Server to connect to if shell doesn't have cmdlets in memory $DLPrefix = '[DL] ' #Display name standard prefix. If none, leave as two single-quotes function ConnectToExchange { $testcmd = gcm Get-Mailbox -ErrorAction SilentlyContinue if (-not($testcmd)) { $statusBarPanel1.Text = 'Connecting to Exchange...' #Connect remotely to Exchange $global:exsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://$connectToServer/PowerShell" -Name exchange Import-PSSession $exsession -AllowClobber -DisableNameChecking | Out-Null } $statusBarPanel1.Text = 'Connected to Exchange' } #region Import the Assemblies [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null #endregion #region Generated Form Objects $form = New-Object System.Windows.Forms.Form $txtAddOwner = New-Object System.Windows.Forms.TextBox $label7 = New-Object System.Windows.Forms.Label $label6 = New-Object System.Windows.Forms.Label $btnRemoveOwner = New-Object System.Windows.Forms.Button $btnAddOwner = New-Object System.Windows.Forms.Button $lstOwners = New-Object System.Windows.Forms.ListBox $label2 = New-Object System.Windows.Forms.Label $label1 = New-Object System.Windows.Forms.Label $btnGetOwner = New-Object System.Windows.Forms.Button $statusBar1 = New-Object System.Windows.Forms.StatusBar $btnCancel = New-Object System.Windows.Forms.Button $btnApply = New-Object System.Windows.Forms.Button $label5 = New-Object System.Windows.Forms.Label $txtDLName = New-Object System.Windows.Forms.TextBox $label4 = New-Object System.Windows.Forms.Label $label3 = New-Object System.Windows.Forms.Label $toolTip1 = New-Object System.Windows.Forms.ToolTip $statusBarPanel1 = New-Object System.Windows.Forms.StatusBarPanel $statusBarPanel2 = New-Object System.Windows.Forms.StatusBarPanel $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState $errorprovider = New-Object System.Windows.Forms.ErrorProvider #endregion Generated Form Objects function DisplayOwners ($DL) { $lstOwners.BeginUpdate() [array]$DLOwners = $DL.ManagedBy foreach ($owner in $DLOwners) { $lstOwners.Items.Add($owner.ToString().Substring($owner.ToString().LastIndexOf('/') + 1)) } $lstOwners.EndUpdate() $txtAddOwner.Enabled = $true } function RetrieveDL { $lstOwners.Items.Clear() #Remove any entries in owner list from previous query $btnAddOwner.Enabled = $false $txtAddOwner.Enabled = $false $statusBarPanel2.Text = 'Searching for DL...' $DLDisplayName = "$($DLPrefix)$($txtDLName.Text)" $script:DL = Get-DistributionGroup $DLDisplayName -ErrorAction SilentlyContinue if (!($DL)) { $errorProvider.SetError($txtDLName, 'The DL cannot be found.') $statusBarPanel2.Text = 'DL not found.' return } #Valid DL returned $errorProvider.SetError($txtDLName, '') DisplayOwners $DL $statusBarPanel2.Text = '' $btnCancel.Text = 'Cancel' } function AddOwner_OnClick ($username) { $statusBarPanel2.Text = 'Validating user...' $ownerMailbox = Get-Mailbox $username -ErrorAction SilentlyContinue if (!($ownerMailbox)) { $errorprovider.SetIconAlignment($txtAddOwner,2) $errorprovider.SetError($txtAddOwner, 'The user cannot be found.') $statusBarPanel2.Text = 'User not found.' return } elseif ($lstOwners.Items.Contains($username)) { $errorprovider.SetIconAlignment($txtAddOwner,2) $errorprovider.SetError($txtAddOwner, 'The user is already in the list.') $statusBarPanel2.Text = 'User already is owner.' return } #Valid user found $lstOwners.Items.Insert(0,$username) #Add owner to top of list $statusBarPanel2.Text = 'User added.' $errorprovider.SetIconAlignment($txtAddOwner,3) $errorprovider.SetError($txtAddOwner,'') $txtAddOwner.Text = '' $btnApply.Enabled = $true } function ToggleAddButton ($username) { if ($username.Length -gt 0) { $btnAddOwner.Enabled = $true } else { $btnAddOwner.Enabled = $false } } function RemoveOwner_OnClick ($owner) { $lstOwners.Items.Remove($owner) $btnRemoveOwner.Enabled = $false $btnApply.Enabled = $true } function ApplyChanges_OnClick { [array]$newOwners = $lstOwners.Items try { Set-DistributionGroup $($DL.DisplayName) -ManagedBy $newOwners -BypassSecurityGroupManagerCheck -ErrorAction Stop $statusBarPanel2.Text = 'DL ownership applied.' $errorprovider.SetError($btnApply, '') $btnCancel.Text = 'Close' $btnApply.Enabled = $false } catch { $statusBarPanel2.Text = 'Error occurred updating DL.' $errorprovider.SetError($btnApply, "Error occurred when updating the DL's new ownership.") } } $OnLoadForm_StateCorrection = {$form.WindowState = $InitialFormWindowState} #region Generated Form Code $form.CancelButton = $btnCancel $form.Text = "Change Distribution List Owner" $form.Name = "form" $form.KeyPreview = $True $form.StartPosition = 1 $form.DataBindings.DefaultDataSourceUpdateMode = 0 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 342 $System_Drawing_Size.Height = 363 $form.ClientSize = $System_Drawing_Size $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 84 $System_Drawing_Size.Height = 20 $txtAddOwner.Size = $System_Drawing_Size $txtAddOwner.DataBindings.DefaultDataSourceUpdateMode = 0 $txtAddOwner.Text = "Enter username" $txtAddOwner.Name = "txtAddOwner" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 30 $System_Drawing_Point.Y = 211 $txtAddOwner.Location = $System_Drawing_Point $txtAddOwner.Enabled = $False $txtAddOwner.TabIndex = 15 $txtAddOwner.add_Enter({if ($txtAddOwner.Text -eq 'Enter username') {$txtAddOwner.Text = ''}}) $txtAddOwner.add_KeyUp({ToggleAddButton $txtAddOwner.Text}) $txtAddOwner.add_KeyDown({if ($_.KeyCode -eq "Enter"){AddOwner_OnClick $txtAddOwner.Text}}) $form.Controls.Add($txtAddOwner) $label7.TabIndex = 12 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 20 $System_Drawing_Size.Height = 23 $label7.Size = $System_Drawing_Size $label7.Text = "2." $label7.Font = New-Object System.Drawing.Font("Arial",9,0,3,0) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 13 $System_Drawing_Point.Y = 108 $label7.Location = $System_Drawing_Point $label7.DataBindings.DefaultDataSourceUpdateMode = 0 $label7.Name = "label7" $form.Controls.Add($label7) $label6.TabIndex = 13 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 283 $System_Drawing_Size.Height = 35 $label6.Size = $System_Drawing_Size $label6.Text = "Add and remove owners as necessary, then click Apply Changes to update the DL's ownership." $label6.Font = New-Object System.Drawing.Font("Arial",8,0,3,0) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 30 $System_Drawing_Point.Y = 109 $label6.Location = $System_Drawing_Point $label6.DataBindings.DefaultDataSourceUpdateMode = 0 $label6.Name = "label6" $form.Controls.Add($label6) $btnRemoveOwner.TabIndex = 7 $btnRemoveOwner.Name = "btnRemoveOwner" $btnRemoveOwner.Enabled = $False $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 75 $System_Drawing_Size.Height = 23 $btnRemoveOwner.Size = $System_Drawing_Size $btnRemoveOwner.UseVisualStyleBackColor = $True $btnRemoveOwner.Text = "Remove" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 30 $System_Drawing_Point.Y = 252 $btnRemoveOwner.Location = $System_Drawing_Point $btnRemoveOwner.DataBindings.DefaultDataSourceUpdateMode = 0 $btnRemoveOwner.add_Click({RemoveOwner_OnClick $lstOwners.SelectedItem}) $form.Controls.Add($btnRemoveOwner) $btnAddOwner.TabIndex = 6 $btnAddOwner.Name = "btnAddOwner" $btnAddOwner.Enabled = $False $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 75 $System_Drawing_Size.Height = 23 $btnAddOwner.Size = $System_Drawing_Size $btnAddOwner.UseVisualStyleBackColor = $True $btnAddOwner.Text = "Add" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 30 $System_Drawing_Point.Y = 181 $btnAddOwner.Location = $System_Drawing_Point $btnAddOwner.DataBindings.DefaultDataSourceUpdateMode = 0 $btnAddOwner.add_Click({AddOwner_OnClick $txtAddOwner.Text}) $form.Controls.Add($btnAddOwner) $lstOwners.FormattingEnabled = $True $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 141 $System_Drawing_Size.Height = 134 $lstOwners.Size = $System_Drawing_Size $lstOwners.DataBindings.DefaultDataSourceUpdateMode = 0 $lstOwners.Name = "lstOwners" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 120 $System_Drawing_Point.Y = 155 $lstOwners.Location = $System_Drawing_Point $lstOwners.TabIndex = 5 $lstOwners.add_SelectedIndexChanged({$btnRemoveOwner.Enabled = $true}) $form.Controls.Add($lstOwners) $label2.TabIndex = 10 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 21 $System_Drawing_Size.Height = 23 $label2.Size = $System_Drawing_Size $label2.Text = "1." $label2.Font = New-Object System.Drawing.Font("Arial",9,0,3,0) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 12 $label2.Location = $System_Drawing_Point $label2.DataBindings.DefaultDataSourceUpdateMode = 0 $label2.Name = "label2" $form.Controls.Add($label2) $label1.TabIndex = 11 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 288 $System_Drawing_Size.Height = 32 $label1.Size = $System_Drawing_Size $label1.Text = "Enter the display name of the DL and click Get Owners to display the ownership." $label1.Font = New-Object System.Drawing.Font("Arial",8,0,3,0) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 30 $System_Drawing_Point.Y = 13 $label1.Location = $System_Drawing_Point $label1.DataBindings.DefaultDataSourceUpdateMode = 0 $label1.Name = "label1" $form.Controls.Add($label1) $btnGetOwner.TabIndex = 3 $btnGetOwner.Name = "btnGetOwner" $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 75 $System_Drawing_Size.Height = 23 $btnGetOwner.Size = $System_Drawing_Size $btnGetOwner.UseVisualStyleBackColor = $True $btnGetOwner.Text = "Get Owners" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 120 $System_Drawing_Point.Y = 77 $btnGetOwner.Location = $System_Drawing_Point $btnGetOwner.DataBindings.DefaultDataSourceUpdateMode = 0 $btnGetOwner.add_Click({RetrieveDL}) $form.Controls.Add($btnGetOwner) $statusBar1.ShowPanels = $True $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 342 $System_Drawing_Size.Height = 22 $statusBar1.Size = $System_Drawing_Size $statusBar1.TabIndex = 14 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 0 $System_Drawing_Point.Y = 341 $statusBar1.Location = $System_Drawing_Point $statusBar1.DataBindings.DefaultDataSourceUpdateMode = 0 $statusBar1.Name = "statusBar1" $statusBar1.Panels.Add($statusBarPanel1)|Out-Null $statusBar1.Panels.Add($statusBarPanel2)|Out-Null $form.Controls.Add($statusBar1) $btnCancel.TabIndex = 9 $btnCancel.Name = "btnCancel" $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 75 $System_Drawing_Size.Height = 23 $btnCancel.Size = $System_Drawing_Size $btnCancel.UseVisualStyleBackColor = $True $btnCancel.Text = "Cancel" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 198 $System_Drawing_Point.Y = 302 $btnCancel.Location = $System_Drawing_Point $btnCancel.DataBindings.DefaultDataSourceUpdateMode = 0 $btnCancel.DialogResult = 2 $form.Controls.Add($btnCancel) $btnApply.TabIndex = 8 $btnApply.AutoSize = $True $btnApply.Name = "btnApply" $btnApply.Enabled = $False $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 88 $System_Drawing_Size.Height = 23 $btnApply.Size = $System_Drawing_Size $btnApply.UseVisualStyleBackColor = $True $btnApply.Text = "Apply Changes" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 60 $System_Drawing_Point.Y = 302 $btnApply.Location = $System_Drawing_Point $btnApply.DataBindings.DefaultDataSourceUpdateMode = 0 $btnApply.add_Click({ApplyChanges_OnClick}) $form.Controls.Add($btnApply) $label5.TabIndex = 4 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 66 $System_Drawing_Size.Height = 23 $label5.Size = $System_Drawing_Size $label5.Text = "Owner(s):" $label5.Font = New-Object System.Drawing.Font("Arial",9,1,3,1) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 35 $System_Drawing_Point.Y = 156 $label5.Location = $System_Drawing_Point $label5.DataBindings.DefaultDataSourceUpdateMode = 0 $label5.Name = "label5" $form.Controls.Add($label5) $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 198 $System_Drawing_Size.Height = 20 $txtDLName.Size = $System_Drawing_Size $txtDLName.DataBindings.DefaultDataSourceUpdateMode = 0 $txtDLName.MaxLength = 255 $txtDLName.Name = "txtDLName" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 120 $System_Drawing_Point.Y = 48 $txtDLName.Location = $System_Drawing_Point $txtDLName.TabIndex = 2 $txtDLName.add_KeyDown({if ($_.KeyCode -eq "Enter"){RetrieveDL}}) $form.Controls.Add($txtDLName) $label4.TabIndex = 1 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 103 $System_Drawing_Size.Height = 23 $label4.Size = $System_Drawing_Size $label4.Text = "DL Name: $DLPrefix" $label4.Font = New-Object System.Drawing.Font("Arial",9,1,3,1) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 30 $System_Drawing_Point.Y = 51 $label4.Location = $System_Drawing_Point $label4.DataBindings.DefaultDataSourceUpdateMode = 0 $label4.Name = "label4" $form.Controls.Add($label4) $label3.TabIndex = 2 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 10 $System_Drawing_Size.Height = 23 $label3.Size = $System_Drawing_Size $label3.Text = "." $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 138 $System_Drawing_Point.Y = 13 $label3.Location = $System_Drawing_Point $label3.DataBindings.DefaultDataSourceUpdateMode = 0 $label3.Name = "label3" $form.Controls.Add($label3) $toolTip1.ShowAlways = $True $toolTip1.IsBalloon = $True $statusBarPanel1.Name = "statusBarPanel1" $statusBarPanel1.Text = "Connecting to Exchange..." $statusBarPanel1.AutoSize = 2 $statusBarPanel1.Width = 162 $statusBarPanel2.Name = "statusBarPanel2" $statusBarPanel2.Text = "" $statusBarPanel2.AutoSize = 2 $statusBarPanel2.Width = 162 $statusBarPanel2.BorderStyle = 2 $toolTip1.ShowAlways = $True $toolTip1.IsBalloon = $True $toolTip1.AutomaticDelay = 250 $toolTip1.AutoPopDelay = 5000 $toolTip1.ToolTipIcon = [System.Windows.Forms.ToolTipIcon]::Info $txtOwnersTip = "Enter the username of someone to be added as an owner." $txtDLNameTip = "The display name of the DL as it appears in the address book." $toolTip1.SetToolTip($txtDLName,$txtDLNameTip) $toolTip1.SetToolTip($txtAddOwner,$txtOwnersTip) #endregion Generated Form Code $OnLoadForm_StateCorrection = {$form.WindowState = $InitialFormWindowState} $InitialFormWindowState = $form.WindowState $form.add_Load($OnLoadForm_StateCorrection) $form.add_Shown({$form.Activate();ConnectToExchange}) #Action when form is displayed #Show the Form [void] $form.ShowDialog() |