A
A
Anton2017-06-22 21:47:35
PowerShell
Anton, 2017-06-22 21:47:35

powershell script running or stuck?

Hello.
Bosses needed the ability to view the contents of employees' scheduled tasks in their Outlook calendar. To do this, you need to grant rights to edit employee calendars to one account.
foreach ($Mailbox in (Get-Mailbox -ResultSize Unlimited)) { Add-MailboxFolderPermission -identity "$($Mailbox.Name):\Calendar" -AccessRights LimitedDetails -user [email protected] -AccessRights Editor }
Script starts and disappears forever (3 hours for 340 accounts is too much), displaying only >>_ in the console.
I already tried Calendar instead of Calendar, tell me which way to dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2017-06-22
@yellowmew

towards debugging and, for this, splitting the code into steps.
Debug - it will be possible to glue it into a one-liner.
For example, you can put get-mailbox with the -verbose key into separate steps,
you can add a get-mailboxfolderpermission check
Well, again, add verbose to add-mailboxfolderpermission
Well, you can write for debugging what specific identity we will now change, Write-Host $Mailbox.Name

A
akelsey, 2017-06-22
@akelsey

1. ">>_" - syntax error, quotation mark, bracket, etc. not closed. Those. you can wait forever - the script doesn't work -)
2. do you have en-US/en-GB locale for all mailboxes? I doubt. Probably Russian, the Calendar folder for the Russian locale will be called "Calendar". Such is Exchange.
3. in general, it's bad practice to immediately poison the script for all users, it's better to "get-mailbox IIvanov" and see what happens
4. I guess the error is somewhere here: "$($Mailbox.Name):\Calendar", but I'm not sure - ) no time to check.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question