I am trying to get MailBoxFolderpermission from diffrent users. I have diffrent tenants where i need to connect and get those. But problems is that i have some folder names in english and other in my own language so i need to make loop or comparison operator which is checking bot languages. Because i dont know which tenants are using my language and which are in english.
This is working:
Get-MailBoxFolderPermission -Identity $userAsked":\FolderName" | select FolderName, User, AccessRights
Those are not working: 1.
$permCalendar = Get-MailBoxFolderPermission -Identity $userAsked | where-object {$_.FolderName -eq ":\FolderName" -or ":\Calendar"} | select FolderName, User, AccessRights
Not working: 2.
if($_.FolderType -eq ":\FolderName") {
Get-MailBoxFolderPermission -Identity $userAsked":\FolderName" | select FolderName, User, AccessRights
} elseif ($_.FolderType -eq ":\Calendar") {
Get-MailBoxFolderPermission -Identity $userAsked":\Calendar" | select FolderName, User, AccessRights
} else {
Write-Host ""
}
CodePudding user response:
Microsoft made it hard by localizing foldernames like that.
However, it can be done if you first query for the localized Name or the FolderID of what is called Calendar
in English and use that instead:
$calendar = Get-MailboxFolderStatistics -Identity $userAsked -FolderScope Calendar |
Where-Object { $_.FolderType -eq 'Calendar'} | Select-Object Name, FolderId
Now you can do the rest of your script using either the $calendar.Name
or the $calendar.FolderId
Get-MailboxFolderPermission -Identity $userAsked":\$($calendar.FolderId)"