I often run scripts through a number mailboxes, and mostly its setting default permission on users calendars. (as an example).
If you have done this in a multi language environment, you will quickly run into a common problem. Is the users folder (calendar) called Calendar, or Kalender (danish – could be in any given language).
You could just try one – if it fails, then the other (but this becomes inefficient fast, with a growing number of languages).
Why not just ask the mailbox it self. Much better, and in the end – a lot easier 🙂
Lets put a user in $User
$User = "Dal"
get-MailboxFolderStatistics -Identity $user -FolderScope Calendar
Now i realize that a fraction of users can return more than one, and we really only want the name, so lets “evolve” our command a bit, by selecting only the first (original):
(Get-MailboxFolderStatistics -Identity $user -FolderScope Calendar | Select-Object -First 1).name
This will in my case return: Kalender
and to expand i a bit more:
$cal = ($user + ":\" +(Get-MailboxFolderStatistics -Identity $user -FolderScope Calendar | Select-Object -First 1).Name)
$cal will contain the entire path to my calendar and is easily used to set permissions
$cal = ($user+":\"+(Get-MailboxFolderStatistics -Identity $user -FolderScope Calendar | Select-Object -First 1).Name) Set-MailboxFolderPermission -User "Default" -AccessRights "reviewer" -Identity $cal
Thats it. No more check, no localized confusion, and its pretty clean 🙂
Helped me a lot, so hope it can help you too.