Exchange Powershell help

Soldato
Joined
25 Nov 2004
Posts
3,792
Hi all

I have a script I need to modify but I am not a powershell master of any kind so am unsure what I need to do, or what will work.

Basically, the business wanted to change all calendar permissions to "reviewer" for the user "default". I did this by exporting users in one OU at a time to a text file and then applying the script to that list of users, like this:

Get-content C:\Calendar.txt | ForEach-Object {Set-MailboxFolderPermission $_":\Calendar" -User Default -AccessRights Reviewer}

Now we have an issue that I am trying to provide a work around for until the issue is resolved and that means running this script on our Users OU every week, via a scheduled task. My thinking is I need to replace the "Get-content C:\Calendar.txt" bit with a command that will get all users in a given OU and then pipe that through to the ForEach command.

Anyone able to help me construct this script? Thanks in advance :)

EDIT: I guess I could run a 2 step scheduled task. Export all users in the OU to a text file as step one and then run this script as step 2. That would capture any new users created within the last week. Just wondering if there is a more elegant, on-the-fly way of doing it.
 
Last edited:
Is it for all users or just a select few in a specific OU?
If it's all users then:
Get-Mailbox -ResultSize Unlimited | Set-MailboxFolderPermission $_":\Calendar" -User Default -AccessRights Reviewer

For specific users in an OU:

Get-Mailbox -OrganizationalUnit "OU=Users,OU=blah,DC=domain,DC=com" -ResultSize Unlimited | Set-MailboxFolderPermission $_":\Calendar" -User Default -AccessRights Reviewer

They are both crude but should work.

Also depending on what version of Exchange you are running, you can set a policy for the default permissions:
https://community.spiceworks.com/ho...-calendar-access-permissions-in-exchange-2010
 
Is it for all users or just a select few in a specific OU?
If it's all users then:
Get-Mailbox -ResultSize Unlimited | Set-MailboxFolderPermission $_":\Calendar" -User Default -AccessRights Reviewer

For specific users in an OU:

Get-Mailbox -OrganizationalUnit "OU=Users,OU=blah,DC=domain,DC=com" -ResultSize Unlimited | Set-MailboxFolderPermission $_":\Calendar" -User Default -AccessRights Reviewer

They are both crude but should work.

Also depending on what version of Exchange you are running, you can set a policy for the default permissions:
https://community.spiceworks.com/ho...-calendar-access-permissions-in-exchange-2010

Perfect, thank you. That default policy applies only to federated domains. I have it set anyway but it makes no difference. This is why you have to use the "Scripting Agent" in order to set certain things when a mailbox is created, this is one of those things. This is what is not working. If a mailbox is created on a CAS/HUB server (we split out our roles) then it isn't applying the Calendar permissions set in the scripting agent. If the mailbox is created on a DAG server then it does. So, until we figure out why I am just trying to get this script running as a scheduled task to run weekly.
 
Back
Top Bottom