Powershell Documentation
I am trying to write a Powershell script to do some cleanup on user mailboxes, before removing them from Exchange. It seems that Exchange does not clean up things like delegates, and ad permissions of deleted mailboxes. I was starting to play around with writing a script like the one below: $SearchUser = "Wilder, Jason" $DelMailboxes = Get-MailboxCalendarSettings -ResultSize Unlimited | Where-Object {$_.ResourceDelegates -match $SearchUser} Foreach ( $Mailbox in $DelMailboxes ) { "User is a delegate for the following mailboxes:" $Mailbox.Identity "Delegates of the mailbox:" $Mailbox.ResourceDelegates } When I created the $Mailbox.ResourceDelegates, it exposed some methods, properties, and functions that I didn't know existed, such as: $Mailbox.ResourceDelegates.Add(AdObjectId item) $Mailbox.ResourceDelegates.Clear(AdObjectId item) $Mailbox.ResourceDelegates.Insert(Int32 index, AdObjectId item) $Mailbox.ResourceDelegates.Remove(AdObjectId item) Does anyone know how to use these, or if there is any documentation on these?
December 23rd, 2010 1:06pm

The documentation will be buried somewhere in the MSDN dotnet documentation for a mailbox object. I don't have a link to that reference, but the add, remove, and set-mailboxfolderpermission cmdlets should make needing to use those method calls unnecessary.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
December 23rd, 2010 1:55pm

Hi jwilder, If you want to develop a complicated script, I would suggest you go to Development forum to seek the solution: http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads Frank Wang TechNet Subscriber Support in forum If you have any feedback on our support, please contact tngfb@microsoft.com Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
December 24th, 2010 4:23am

Which add/remove cmdlets? I need to know where to remove before I can call a cmdlet. It seems like if I can find the account on the object, and remove it at the same time, it would be faster. Like: $SearchUser = "UserA" $DelMailboxes = Get-MailboxCalendarSettings -ResultSize Unlimited | Where-Object {$_.ResourceDelegates -match $SearchUser} Foreach ( $Mailbox in $DelMailboxes ) { "User is a delegate for the following mailboxes:" $Mailbox.Identity "Delegates of the mailbox:" $Mailbox.ResourceDelegates.Remove("UserA") } If it works that way?
Free Windows Admin Tool Kit Click here and download it now
December 28th, 2010 12:36pm

Thanks, I'll try that. The realms of Admin and Developer are starting to get mixed up.
December 28th, 2010 12:37pm

For resourcedelegates, you'd use Set-MailboxCalendarSettings -ResourceDelegates This will take care of any resource mailboxes the user was a delegate of, but won't address any other mailbox/folder delegations. Assuming this is Exchange 2007, you may need to look to the EWS Managed API for that.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
December 28th, 2010 1:55pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics