none
Exporting FullAccess and SendAs permission RRS feed

  • General discussion

  • Hi, 

    I am using this script to export both permissions. Problem is i am getting them all in separate line. So if ABC mailbox is accessed by 3 users, then there are 3 times name of ABC and then permission. 

    $SendAs= @()
    $FullAccess= @()

    $Mailboxes = Import-Csv 'C:\Users\aa\Desktop\Important Scripts\Export Mailbox Permissions O365\Mailboxes.csv' 
    ForEach ($Mailbox in $Mailboxes) {
    $SendAs+= Get-RecipientPermission $Mailbox.Email | ? {$_.AccessRights -like "SendAs" } | select identity, Trustee, accessrights
    $FullAccess+= Get-MailboxPermission $Mailbox.Email | ? {$_.AccessRights -eq "FullAccess" -and !$_.IsInherited } | select identity, user, accessrights
     
     }
    $SendAs | Export-Csv 'C:\Users\aa\Desktop\Important Scripts\Export Mailbox Permissions O365\PermissionSendAsResult.csv' -NoTypeInformation
    $FullAccess | Export-Csv 'C:\Users\aa\Desktop\Important Scripts\Export Mailbox Permissions O365\PermissionFullAccessResult.csv' -NoTypeInformation

    Is there anyway that i can get all users who are accessing mailbox in one cell? It shows one user (who has access) per row. So if mailbox is accessed by 5 users, there will be 5 separate rows for mailbox. I want them all in one cell or at least in one row if possible. 


    Hasan

    • Changed type Bill_Stewart Tuesday, November 21, 2017 6:55 PM
    • Moved by Bill_Stewart Tuesday, November 21, 2017 6:55 PM Help vampire
    Tuesday, June 27, 2017 8:00 PM

All replies

  • You would use a custom object and "join" all of the returned rows.

    \_(ツ)_/

    Tuesday, June 27, 2017 9:09 PM
  • You would use a custom object and "join" all of the returned rows.

    \_(ツ)_/

    How i can modify script? 

    Hasan

    Tuesday, June 27, 2017 9:33 PM
  • By adding a custom object for each mailbox.

    https://technet.microsoft.com/en-us/library/hh750381.aspx


    \_(ツ)_/

    Tuesday, June 27, 2017 9:34 PM
  • select identity, user, @{Expression={$_.accessrights -join ';'};Label="accessrights"}
    Tuesday, June 27, 2017 9:43 PM
  • select identity, user, @{Expression={$_.accessrights -join ';'};Label="accessrights"}

    Hi Jon, 

    Output is same. I am trying to work on USER part, so tried this on USER but same result. Still each user is on separate row. Actually what you suggesting is for exporting multi-value attribute like email addresses. Here i want separate values as multivalued output. 


    Hasan


    Tuesday, June 27, 2017 10:15 PM
  • What is "user".  You need to enumerate the access permissions and join them.

    What you are trying to accomplish does not make much sense.  What is the final output you are looking for.

    Try this to see what I am referring to.

    $mailboxes |
    	ForEach-Object{
    		$mbx = $_
    		Get-RecipientPermission $mbx.Email |
    			Where-Object{ $_.AccessRights -like 'SendAs' } |
    			Add-Member -MemberType NoteProperty -Name Mailbox -Value $mbx.Email -PassThru
    	} |
    Select-Object Mailbox, identity, user, accessrights

    Look at the output and try to understand why your request is flawed.  Review the whole permissions list for a single mailbox.  There is really no way to put all of this in to one column.

    If you want a formatted report then use "GroupBy Mailbox" on the "Format-Table" command.

    $mailboxes |
    	ForEach-Object{
    		$mbx = $_
    		Get-RecipientPermission $mbx.Email |
    			Where-Object{ $_.AccessRights -like 'SendAs' } |
    			Add-Member -MemberType NoteProperty -Name Mailbox -Value $mbx.Email -PassThru
    	} |
    	Format-Table -GroupBy Mailbox -Property Trustee, accessrights


    \_(ツ)_/


    • Edited by jrv Tuesday, June 27, 2017 10:44 PM
    Tuesday, June 27, 2017 10:39 PM
  • What is "user".  You need to enumerate the access permissions and join them.

    What you are trying to accomplish does not make much sense.  What is the final output you are looking for.

    Try this to see what I am referring to.

    $mailboxes |
    	ForEach-Object{
    		$mbx = $_
    		Get-RecipientPermission $mbx.Email |
    			Where-Object{ $_.AccessRights -like 'SendAs' } |
    			Add-Member -MemberType NoteProperty -Name Mailbox -Value $mbx.Email -PassThru
    	} |
    Select-Object Mailbox, identity, user, accessrights

    Look at the output and try to understand why your request is flawed.  Review the whole permissions list for a single mailbox.  There is really no way to put all of this in to one column.

    If you want a formatted report then use "GroupBy Mailbox" on the "Format-Table" command.

    $mailboxes |
    	ForEach-Object{
    		$mbx = $_
    		Get-RecipientPermission $mbx.Email |
    			Where-Object{ $_.AccessRights -like 'SendAs' } |
    			Add-Member -MemberType NoteProperty -Name Mailbox -Value $mbx.Email -PassThru
    	} |
    	Format-Table -GroupBy Mailbox -Property Trustee, accessrights


    \_(ツ)_/


    Ok. 

    Current output is like this:

    I want output like this:


    Or like this


    Hasan

    Wednesday, June 28, 2017 2:41 PM
  • Why do you need that kind of output?

    Just export to CSV, import into a spreadsheet, and create a pivot table.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, June 28, 2017 3:02 PM
  • Why do you need that kind of output?

    Just export to CSV, import into a spreadsheet, and create a pivot table.


    -- Bill Stewart [Bill_Stewart]

    I usually get request to export permissions of 200 mailboxes so they can review. They want one mailbox per row instead of seeing same mailbox 4-5 times because it is accessed by 5 users. 

    Also companies migrate to our environment and when we migrate shared mailboxes with permissions and then to import them in our environment, it is easier if they are one mailbox per row. 


    Hasan

    Wednesday, June 28, 2017 3:39 PM
  • To get that output, as I said, you can import into a spreadsheet and cross-tabulate (pivot table).

    -- Bill Stewart [Bill_Stewart]

    Wednesday, June 28, 2017 4:00 PM
  • To get that output, as I said, you can import into a spreadsheet and cross-tabulate (pivot table).

    -- Bill Stewart [Bill_Stewart]

    Can you help me. I tried pivot table but it is just grouping not doing what i want. 

    Hasan

    Wednesday, June 28, 2017 4:05 PM
  • If you have questions about how to use your spreadsheet, this is not the right place to ask.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, June 28, 2017 4:47 PM
  • If you have questions about how to use your spreadsheet, this is not the right place to ask.

    -- Bill Stewart [Bill_Stewart]

    So using script is not possible? Like we cannot have results like i want? 

    Hasan

    Wednesday, June 28, 2017 4:59 PM
  • If you have questions about how to use your spreadsheet, this is not the right place to ask.


    -- Bill Stewart [Bill_Stewart]

    So using script is not possible? Like we cannot have results like i want? 

    Hasan


    As noted before.  You can combine all using "-join" but that would give an unreadable and possibly extremely long column.  I recommend using Bill's suggestion.

    \_(ツ)_/

    Wednesday, June 28, 2017 5:02 PM
  • If you have questions about how to use your spreadsheet, this is not the right place to ask.


    -- Bill Stewart [Bill_Stewart]

    So using script is not possible? Like we cannot have results like i want? 

    Hasan


    As noted before.  You can combine all using "-join" but that would give an unreadable and possibly extremely long column.  I recommend using Bill's suggestion.

    \_(ツ)_/

    HI JRV, 

    I want to do that. How i can modify this line to get all "User" in one cell. 

    Get-MailboxPermission $Mailbox.Email | ? {$_.AccessRights -eq "FullAccess" -and !$_.IsInherited } | select identity, user, @{Name='accessrights';Expression={[string]::join(";",@($_.accessrights))}}


    Hasan

    Wednesday, July 12, 2017 9:26 PM