none
Folderpermission via shell RRS feed

  • Question

  • Hi,

    I want to set the permission for some mailboxes by powershell:

    Foreach ($Mailbox in (Get-Mailbox -ResultSize Unlimited)) { Set-MailboxFolderPermission –identity “$($Mailbox.Name):\Inbox” -AccessRights Owner –User Default}

    This works fine for English mailboxes. For other languages I get en error. Is it possible to filter all mailboxes from type inbox and pipe it to the script on top?

    Who has some experience and can assist?

    Best regards
    Christian


    __________________
    Viele Grüße
    Christian

    Monday, September 5, 2011 2:36 PM

Answers

All replies

  • Have you tried using

    “$($Mailbox.alias):\Inbox”

    as your folder identity parameter instead of .name?


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Monday, September 5, 2011 3:03 PM
  • Hi mjolinor,

    THX for your replay! :-)

    “$($Mailbox.alias):\Inbox”

    as your folder identity parameter instead of .name?

    Nop, it does not depends on the name/alias. It is a result of the folder name: english - Inbox / german - Posteingang.

    Do you have some more ideas?


    __________________
    Viele Grüße
    Christian

    Monday, September 5, 2011 4:29 PM
  • Use get-mailboxfolderstatistics | select identity to get the mailbox folder heirarchy, and then use that to filter the ones that have an \Inbox folder? 
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Monday, September 5, 2011 4:41 PM
  • Hi mjolinor,

    Use get-mailboxfolderstatistics | select identity to get the mailbox folder heirarchy, and then use that to filter the ones that have an \Inbox folder? 

    I can filter the folder from type inbox but only for the admin:
    Get-MailboxFolder administrator -Recurse| where-object {$_.Defaultfoldertype -eq "inbox"}

    It is this behavior:
    http://blogs.technet.com/b/ilvancri/archive/2010/08/20/get-mailboxfolder-is-not-working-amp-exchange-web-services-getting-started.aspx

    Now I try to find out how I can give a user full access for get-mailboxfolder to all user...

    Any fast solution?


    ____________________
    Viele Grüße
    Christian

    Monday, September 5, 2011 5:30 PM
  • That's weird.  What does type show a non-admin user?
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Monday, September 5, 2011 6:32 PM
  • Hi mjolinor,

    That's weird.  What does type show a non-admin user?

    Mailbox does not exist - like you can see in the link.
    This works:
    Get-MailboxFolder administrator -Recurse| where-object {$_.Defaultfoldertype -eq "inbox"}| Set-MailboxFolderPermission -AccessRights Owner -User Default

    This not:
    Get-MailboxFolder hans5 -Recurse| where-object {$_.Defaultfoldertype -eq "inbox"}| Set-MailboxFolderPermission -AccessRights Owner -User Default
    Das angegebene Postfach "hans5" ist nicht vorhanden.
       + CategoryInfo          : NotSpecified: (0:Int32) [Get-MailboxFolder], ManagementObjectNotFoundException
       + FullyQualifiedErrorId : 792FA62D,Microsoft.Exchange.Management.StoreTasks.GetMailboxFolder


    ____________________
    Viele Grüße
    Christian

    Monday, September 5, 2011 7:10 PM
  • I'm confused. Is the problem with resolving the mailbox identity, or the folder name? 
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Monday, September 5, 2011 7:17 PM
  • The link appears to be about an RBAC issue. This still seems to be a name resolution problem.

    set-mailboxfolderpermission want either the mailbox alias or smtp address as the mailbox identifier part of the mailbox:\folder identity.  If the $mailbox.name is the same as $mailbox.alias then using $mailbox.name wil work. If they are different it will fail.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Monday, September 5, 2011 7:34 PM
  • Hi mjolinor,

    The link appears to be about an RBAC issue. This still seems to be a name resolution problem.

    set-mailboxfolderpermission want either the mailbox alias or smtp address as the mailbox identifier part of the mailbox:\folder identity.  If the $mailbox.name is the same as $mailbox.alias then using $mailbox.name wil work. If they are different it will fail.

    Name and alias ar the same:
    [PS] C:\Windows\system32>get-mailbox |ft name, alias

    Name                               Alias
    ----                               -----
    Administrator                      Administrator
    Hans1                              Hans1
    Hans2                              Hans2
    Hans3                              Hans3
    Hans4                              Hans4
    Hans5                              Hans5

    Same error with the smtp address...

    The cmdlet is not allowed to run against other mailboxes. Let's see if there is a way...


    __________________
    Viele Grüße
    Christian

    Tuesday, September 6, 2011 5:04 AM
  • Okay. If it is an RBAC issue, there is a way to test that. 

    Load the management snapin into a generic PS session, and see if it works then. 

     add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

     

    This bypasses the remoting environment, and RBAC controls.  It's not recommended that you do this for production work (not supported by Microsofte), but it should verify that the problem is with RBAC.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Tuesday, September 6, 2011 10:44 AM
  • I also went back and reviewed that article, and noticed that at the bottom of the comments, some had suggested using get-mailboxfolderstatistics and selecting just the folder IDs from the results to get the list of folder names.

    I had suggested this in my second post, but the reply to that was the about the results of using get-mailboxfolder.

    Did you try get-mailboxfolderstatistics to get the list of folder names, and if so, what were the results?


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Tuesday, September 6, 2011 11:06 AM
  • Hi mjolinor,

    Thank you very much for your reply!!!

    Did you try get-mailboxfolderstatistics to get the list of folder names, and if so, what were the results?

    get-mailboxfolderstatistics ist OK to get all folder - but whichone ist the inbox/Posteingang/...? I believe I can not filter the type but I will check...

    THX
     -- __________________
    Viele Grüße
    Christian

    Tuesday, September 6, 2011 11:10 AM
  • I'm not sure if it gives you the type, but since there seems to be a limited number of possible names for the Inbox, you could test the collection for one of a collection of possible values.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Tuesday, September 6, 2011 11:21 AM
  • Hi,

    I guess you could change this script so it applies to inbox folder.

    http://gallery.technet.microsoft.com/scriptcenter/19b98a56-42aa-4695-b07c-335d8322b64e

    Thursday, September 8, 2011 11:40 PM
  • Hi egelandc,

    http://gallery.technet.microsoft.com/scriptcenter/19b98a56-42aa-4695-b07c-335d8322b64e

    Yes, folderstatistic with a scope was the trick:
    Get-MailboxFolderStatistics -FolderScope Calendar

    THX!!!


    __________________
    Viele Grüße
    Christian

    Friday, September 9, 2011 10:52 AM
  • Hi egelandc,

    http://gallery.technet.microsoft.com/scriptcenter/19b98a56-42aa-4695-b07c-335d8322b64e

    Yes, folderstatistic with a scope was the trick:
    Get-MailboxFolderStatistics -FolderScope Calendar

    THX!!!


    __________________
    Viele Grüße
    Christian

    Friday, September 9, 2011 11:52 AM