No one has responded to this discussion for at least a year, so this information may be out of date. If you're looking for information about this topic, please search for a more recent discussion or post a new question.

Export all users calendar permissions to a csv file

  • 2 Followers
  • 20 Replies |
  • This post has 1 verified answer |
Answered (Verified) This question is answered

Hi,

 

I'm using the commands below to see the calendar folder permissions of all users of my organization.

 

foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) {

$cal = $user.alias

Get-MailboxFolderPermission -Identity $cal":\Calendário"

}

 

PS: The folder's name really is "Calendário". Brazil here.

It works but, I need two more things:

 

1 - I don't want to get the information on the screen. I want to export to a CSV file. Adding the "Export-CSV C:\File.csv" at the end of the commands don't work.

2- I need to know which user owns that calendars.

 

This is one example of the output I get:

RunspaceId   : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152
FolderName   : Calendário
User         : Padrão
AccessRights : {AvailabilityOnly}
Identity     : Padrão
IsValid      : True

RunspaceId   : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152
FolderName   : Calendário
User         : Anônimo
AccessRights : {None}
Identity     : Anônimo
IsValid      : True

RunspaceId   : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152
FolderName   : Calendário
User         : Padrão
AccessRights : {AvailabilityOnly}
Identity     : Padrão
IsValid      : True

RunspaceId   : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152
FolderName   : Calendário
User         : Anônimo
AccessRights : {None}
Identity     : Anônimo
IsValid      : True

RunspaceId   : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152
FolderName   : Calendário
User         : Padrão
AccessRights : {AvailabilityOnly}
Identity     : Padrão
IsValid      : True

RunspaceId   : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152
FolderName   : Calendário
User         : Anônimo
AccessRights : {None}
Identity     : Anônimo
IsValid      : True

RunspaceId   : 818527fd-fa32-4d6f-b7a6-ae7ac6e32152
FolderName   : Calendário
User         : Padrão
AccessRights : {AvailabilityOnly}
Identity     : Padrão
IsValid      : True

 

 

 

I need this info to apply audit only to accounts that shares calendars.

PS: If anyone knows how to put that commands in only one command line, please tell me.

 

Thanks in advance.

  • Post Points: 155
Verified Answer
  • Samuel,

     

    Please ignore my last post.

    I was trying to run the script line by line to see what I was doing wrong here.

    So I found the problem...

     

    See the bold part in this line of the script:

    $permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"}

     

    My Office 365 language is portuguese, so I changed it to "Padrão" and changed the operator to "-ne" (I want the permissions of the no-default users only).

     

    Saved the Calendar.ps1 file after the modifications and the csv file was created successfully wtih the informations that I wanted.

     

    Thank you SO MUCH for your time and patience.

    Sorry for anything else.

    • Not Ranked
    • Post Points: 0
All Replies
  • Hi Vandrey,

    I understand that you want to export calendar information to a csv file via PowerShell.

    Please try your cmdlet by adding -notype.
    For example:  Export-CSV -Path ".\cloud.csv" –notype

    Thanks,
    Bourne Zhang

    • Top 25 Contributor
    • Male
    • Post Points: 0
  • Hi Bourne,

    I know how to export using that command.

    But that command doesn't work if I put it in the end of the script, after the "}".

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey,

    Thanks for your post in the forum.

    Looking at Bourne's post and the command, Please try running the PowerShell as below and report back.

    Foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) {

    $cal = $user.alias

    Get-MailboxFolderPermission -Identity $cal":\Calendário"


    Export-CSV -Path ".\cloud.csv" –notype

    }

    Best regards

    Samuel

    Samuel A Girod MSFT
    • Top 150 Contributor
    • Post Points: 0
  • Hi Samuel,

    I tried to run the command just like you told me:

    ----------------------------------------------------------------------------------------------------------------

    PS C:\Windows\system32> foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) {

    >> $cal = $user.alias

    >> Get-MailboxFolderPermission -Identity $cal":\Calendário"

    >> Export-Csv -Path "c:\teste.csv" -notype

    >> }

    >>

    ----------------------------------------------------------------------------------------------------------------

    And the output is this:

    ----------------------------------------------------------------------------------------------------------------

    RunspaceId   : e49ce3ac-de06-46f6-b711-69040176391a

    FolderName   : Calendário

    User         : Padrão

    AccessRights : {AvailabilityOnly}

    Identity     : Padrão

    IsValid      : True

    RunspaceId   : e49ce3ac-de06-46f6-b711-69040176391a

    FolderName   : Calendário

    User         : Anônimo

    AccessRights : {None}

    Identity     : Anônimo

    IsValid      : True

    cmdlet Export-Csv na posição de comando 1 do pipeline

    Forneça valores para os seguintes parâmetros:

    InputObject:

    ----------------------------------------------------------------------------------------------------------------

    The content of the csv file is this:

    ----------------------------------------------------------------------------------------------------------------

    #TYPE System.String

    "Length"

    "0"

    ----------------------------------------------------------------------------------------------------------------

    Any idea?

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey,

    Thanks for the quick response. I have another suggestion please see below

    Foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) {

    $cal = $user.alias

    Get-MailboxFolderPermission -Identity $cal":\Calendário" |ft|out-file c:\teste.csv -append 

    }

    Best regards

    Samuel

    Samuel A Girod MSFT
    • Top 150 Contributor
    • Post Points: 0
  • Samuel,

    Thanks for the info.

    But once again there is some problems.

    This is on part of the output of that command:

    _____________________________________________________________________

    RunspaceId    FolderName    User         AccessRights    Identity          IsValid

    ----------             ----------              ----             ------------             --------            -------

    1da743a1-6... Calendário       Padrão     {Availabi...           Padrão         True

    1da743a1-6... Calendário       Anônimo  {None}                 Anônimo      True

    _____________________________________________________________________

    Two problems in there:

    1) I still don't know the name or user of the owner of the calendar

    2) In this table format some info get lost. What aboy if I have four Maria's in my organization? I will not have their complete names to difference on of the others.

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey.

     We are using the user.alias field the other option is to use the SMTP address and see if the report gives us the email address of the user.

    Please try this variation

    Foreach($user in Get-Mailbox -RecipientTypeDetails UserMailBox) {

    $cal = $user.smtp 

    Get-MailboxFolderPermission -Identity $cal":\Calendário" |ft|out-file c:\teste.csv -append



    Best regards

    Samuel

    Samuel A Girod MSFT
    • Top 150 Contributor
    • Post Points: 0
  • Now I got only this:

    RunspaceId    FolderName    User         AccessRights Identity          IsValid

    ----------    ----------    ----         ------------ --------          -------

    e2685fba-8... Calendário    Padrão       {None}       Padrão               True

    RunspaceId    FolderName    User         AccessRights Identity          IsValid

    ----------    ----------    ----         ------------ --------          -------

    e2685fba-8... Calendário    Padrão       {None}       Padrão               True

    RunspaceId    FolderName    User         AccessRights Identity          IsValid

    ----------    ----------    ----         ------------ --------          -------

    e2685fba-8... Calendário    Padrão       {None}       Padrão               True

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey,

    Thank you for your post in the forum.
     
    I suggest you to
    try this:

    Get-mailbox | Get-MailboxPermission | select-object FolderName,User,AccessRights,Identity, IsInherited,IsValid | export-csv -Path c:\teste.csv

    Or

    Get-MailboxFolderPermission -Identity xxxx | export-csv -Path c:\teste.csv

    Should you have any further questions about how to do this, please feel free to let us know? We are here to help.

    Best regards,
    Roger MSF

    • Top 500 Contributor
    • Post Points: 0
  • Hey Roger,

    Not this time...

    The result was a big csv with some info like this:

    ____________________________________________________________________________________________________

    #TYPE Selected.System.Management.Automation.PSCustomObject

    FolderName User AccessRights Identity IsInherited IsValid

    NT AUTHORITY\SELF FullAccess, ExternalAccount, ReadPermission 01 Videoconferencia False True

    LAMPRD80\Domain Admins FullAccess 01 Videoconferencia True True

    ____________________________________________________________________________________________________

    That first command don't show me the folders name. And don't have nothing about the calendar folder in it.

    The second one only works if I type the folder name (Ex.: user:\Calendar) and only works to one user at a time.

    Thx anyway for trying.

    Any1?

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey,

    Thanks for your patience on this issue.

     I have located and tested a script and I include it below. It will create a csv file that list each calendar owner  and the permission.
    You can edit the csv file and use it to change the existing permissions buy importing the csv file after  saving the changes.

    $rptCollection = @()
    $mailboxes = get-mailbox -ResultSize Unlimited
    $mailboxes | foreach-object{
    $alias = $_.alias + ":\Calendar"
    $displayName = $_.DisplayName
    write-host $alias
    $permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"}
    if($permissions -ne $null){
    $stringPerms = ""
    foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "}
    Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force
    Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAccessRights" -Value $stringPerms -Force
    $rptCollection += $permissions
    }
    }
    $rptCollection | export-csv -notypeInformation c:\teste.csv

    Once you have this, simply edit the CSV and update the Access Rights field with the rights you would like to give each user. Once completed, hit save.

    Now you are ready to import. Use the script below to re-import the CSV and update the permissions. 

    import-csv c:\teste.csv | foreach-object{
    "Seting Rights on " + $_.alias
    Set-MailboxFolderPermission -id $_.alias -User $_.Identity -AccessRights $_.StringAccessRights 
     }

    Please let me know if this was helpful

    Best regards,

    Samuel

    Samuel A Girod MSFT
    • Top 150 Contributor
    • Post Points: 0
  • Hey Samuel,

     

    No problem. I thank you for the patience!

    But was not this time...

     

    I've tried the commands like you gave to me:

    ______________________________________________________________________________________________________________________

    PS C:\Windows\system32> $rptCollection = @()

    PS C:\Windows\system32> $mailboxes | ForEach-Object{

    >> $alias = $_.alias + ":\Calendar"

    >> $displayName = $_.DisplayName

    >> write-host $alias

    >> $permissions = Get-MailboxFolderPermission $alias | Where-Object {$._Identity.ToString() -eq "Default"}

    >> if($permissions -ne $null){

    >> $stringPerms = ""

    >> foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "}

    >> Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force

    >> Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAc

    cessRights" -Value $stringPerms -Force

    >> $rptCollection += $permissions

    >> }

    >> }

    >> $rptCollection | Export-Csv -NoTypeInformation C:\Teste.csv

    >>

    An expression was expected after '('

    Line: 5 character: 88

    + $permissions = Get-MailboxFolderPermission $alias | Where-Object {$._Identity

    .ToString( <<<< ) -eq "Default"}

       + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx

      ception

       + FullyQualifiedErrorId : ExpectedExpression

    PS C:\Windows\system32>

    ______________________________________________________________________________________________________________________

    I did something wrong?

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey,
    thanks for the feedback.
     I looked at your listing of what you did and I need to very thjat you copied and pasted the entire routine at the same time.
    In other words you dont run the script line by line  but copy it all and paste in powershell eg:

    --------Start below this line--------------
    $rptCollection = @()
    $mailboxes = get-mailbox -ResultSize Unlimited
    $mailboxes | foreach-object{
    $alias = $_.alias + ":\Calendar"
    $displayName = $_.DisplayName
    write-host $alias
    $permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"}
    if($permissions -ne $null){
    $stringPerms = ""
    foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "}
    Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force
    Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAccessRights" -Value $stringPerms -Force
    $rptCollection += $permissions
    }
    }
    $rptCollection | export-csv -notypeInformation c:\teste.csv

    ----------------Copy everything in between and paste on PowerShell command line then hit enter twice-----------------

    Please try this again and let me know what happens.

    Best regards

    Samuel

    Samuel A Girod MSFT
    • Top 150 Contributor
    • Post Points: 0
  • Hey Samuel,

    Sorry for that...

    I like to use the commands line by line to see what it does. Didn't know that it was the problem.

    But let's go.

    Copied the script below to a .ps1 file:

    ___________________________________________________________________________________________________

    $rptCollection = @()

    $mailboxes = get-mailbox -ResultSize Unlimited

    $mailboxes | foreach-object{

    $alias = $_.alias + ":\Calendário"

    $displayName = $_.DisplayName

    write-host $alias

    $permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"}

    if($permissions -ne $null){

    $stringPerms = ""

    foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "}

    Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force

    Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAccessRights" -Value $stringPerms -Force

    $rptCollection += $permissions

    }

    }

    $rptCollection | export-csv -notypeInformation c:\teste.csv

    ___________________________________________________________________________________________________

    As you can see, the only change I've made is the word "calendar" for "calendário".

    When I run the script it start showing to me all mailboxes that have the folder "Calendário" on it.

    Like this:

    ___________________________________________________________________________________________________

    user1.surname:\Calendário

    user2.surname:\Calendário

    user3.surname:\Calendário

    user4.surname:\Calendário

    user5.surname:\Calendário

    user6.surname:\Calendário

    user7.surname:\Calendário

    Não foi possível executar a operação porque 'user8.surname:\Calendário' não foi en

    contrado.

       + CategoryInfo          : NotSpecified: (:) [Get-MailboxFolderPermission],

       ManagementObjectNotFoundException

       + FullyQualifiedErrorId : 56C8E538,Microsoft.Exchange.Management.StoreTask

      s.GetMailboxFolderPermission

    user9.surname:\Calendário

    user10.surname:\Calendário

    user11.surname:\Calendário

    ___________________________________________________________________________________________________

    At the end of the list (big list, copied only one part of it), it returned to the PS command prompt without showing any error message and the C:\teste.csv file was created but have 0 kb.

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey.

    Thanks for your patience with this issue.

    I have rerun the script from the command line interface pasting the entire script and hitting enter twice.
    It lists on screen each mailbox it finds and outputs to the teste.csv file a line for each mailbox.

    I note you saved the script to a file an then ran the  script. Can you try pasting the entire script to the PowerShell command prompt and run it from there

    Please report back.

    Best regards

    Samuel

    Samuel A Girod MSFT
    • Top 150 Contributor
    • Post Points: 0
  • Hey Samuel,

    Thanks but, again, nothing...

    See the transcript below:

    **********************

    Início da Transcrição do Windows PowerShell

    Hora de início: 20120910135920

    Nome de Usuário  : <ORGANIZATION>\<My_user>

    Computador  : <MACHINE> (Microsoft Windows NT 6.1.7601 Service Pack 1)

    **********************

    Transcrição iniciada, o arquivo de saída é C:\PowerShell.txt

    PS C:\Windows\system32> cls

    PS C:\Windows\system32> $rptCollection = @()

    PS C:\Windows\system32> $mailboxes = get-mailbox -ResultSize Unlimited

    PS C:\Windows\system32> $mailboxes | foreach-object{

    >> $alias = $_.alias + ":\Calendário"

    >> $displayName = $_.DisplayName

    >> write-host $alias

    >> $permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"}

    >> if($permissions -ne $null){

    >> $stringPerms = ""

    >> foreach($perms in $permissions.AccessRights){$stringPerms = $stringPerms + $perms + " "}

    >> Add-Member -InputObject $permissions -MemberType NoteProperty -Name "Alias" -Value $alias -Force

    >> Add-Member -InputObject $permissions -MemberType NoteProperty -Name "StringAccessRights" -Value $stringPerms -Force

    >> $rptCollection += $permissions

    >> }

    >> }

    >> $rptCollection | export-csv -notypeInformation c:\teste.csv

    >>

    user1.lastname:\Calendário

    user2.lastname:\Calendário

    Não foi possível executar a operação porque 'user3.lastname:\Calendário' não foi encontrado.

       + CategoryInfo          : NotSpecified: (:) [Get-MailboxFolderPermission],

       ManagementObjectNotFoundException

       + FullyQualifiedErrorId : 90818296,Microsoft.Exchange.Management.StoreTask

      s.GetMailboxFolderPermission

    user4.lastname:\Calendário

    ...

    user99.lastname:\Calendário

    PS C:\Windows\system32> Stop-Transcript

    **********************

    Fim da Transcrição do Windows PowerShell

    Hora de término: 20120910140831

    **********************

    I've edited the transcript to not show my organization's info and cutted a lot of users lines.

    I wasn't able to double hit enter, because when I paste the script into the powershell window, it begin to run the script.

    Tried here 4 times, pressing enter twice even when the script starts automatically and nothing =/

    Is there a problem of my plan? Exchange Online Plan 1

    • Not Ranked
    • Post Points: 0
  • Samuel,

     

    Please ignore my last post.

    I was trying to run the script line by line to see what I was doing wrong here.

    So I found the problem...

     

    See the bold part in this line of the script:

    $permissions = Get-MailboxFolderPermission $alias | Where-Object {$_.Identity.ToString() -eq "Default"}

     

    My Office 365 language is portuguese, so I changed it to "Padrão" and changed the operator to "-ne" (I want the permissions of the no-default users only).

     

    Saved the Calendar.ps1 file after the modifications and the csv file was created successfully wtih the informations that I wanted.

     

    Thank you SO MUCH for your time and patience.

    Sorry for anything else.

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey,


     Thanks for the follow up. It was with a joint effort that  we were able to get your issue resolved.

    It allows us to have an issue and a verified solution on this thread. This information will help anyone that has a similar issue.

    I will archive the thread with your permission.

    Best regards

    Samuel.


    Samuel A Girod MSFT
    • Top 150 Contributor
    • Post Points: 0
  • Samuel,

    You can archive it.

    One more time, thanks.

    [ ]'s

    • Not Ranked
    • Post Points: 0
  • Hello Vandrey,

    I am archiving the thread today.

    If you have any other questions or concerns, please do not hesitate to contact us. It is always our pleasure to be of assistance.

    Regards,

    Samuel 

    Samuel A Girod MSFT
    • Top 150 Contributor
    • Post Points: 0
Page 1 of 2 (21 items) 1|2|