Office 365 Permissions Inventory scripts vol3

Continuing the Permissions inventory series, I’ve published two more scripts on the TechNet Gallery. Both scripts deal with mailbox folder permissions, in the first case only covering the default Calendar folder.

Both scripts use much of the same code, after all getting the permissions is performed via the Get-MailboxFolderPermission cmdlet. For the Mailbox folder permissions inventory script however, the number of folders covered and thus the number of permission entries gathered is much larger, so some additional optimizations have been made in the code. This includes arrays to specify which folders to cover and which to exclude, as well as a parameter to exclude permission entries from specific users. I’d recommend adjusting those accordingly, especially if you try to run the scripts in large organizations.

Unlike previous scripts in the series, output is written to a CSV file by default – seems I’m the only one that prefers to actually take a look at the output before dumping it to file 🙂 Feedback taken! The scripts will still keep the output in the global $varPermissions variable, in case you want to manipulate it before export. And in case you are having troubles with the session breaking too often, an alternative is provided in order to save the output after each script iteration.

And since we mentioned output – two different variants are included. The default one writes each permission entry to a new line in the CSV file, but you can also use the -CondensedOutput switch to specify that you want to get the “shorter” version, with one line per mailbox folder (or one line per mailbox in the case of the Calendar Permissions script). Examples below, let me know which one you prefer.

permissionsoutput

permissionsoutput1

Anyway, here are the links to the scripts and more detailed descriptions on the Cogmotive blog site:

8 thoughts on “Office 365 Permissions Inventory scripts vol3

  1. Eric Umali says:

    Hello! I’ve been trying to run this script, but I’ve been getting no results except the following error, over and over:

    You cannot call a method on a null-valued expression.
    At C:\%blahblahblah%\Documents\Scripts\Calendar_Permissions_inventory.ps1:128 char:71
    + … nternal”) { $varUser = $entry.User.ADRecipient.PrimarySmtpAddress.ToS …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Any input on what I might be doing wrong, or missing, would be appreciated. Thanks!

    Reply
      1. Eric Umali says:

        Thank you! It works and outputs everything to the console window just fine, but I’m not getting the CSV. That is, it creates a CSV file, but the file is empty.

        Reply
        1. Vasil Michev says:

          That’s because I commented that part… Remove the comment sign in front of Export-CSV 🙂

        2. Eric Umali says:

          Ah-ha! I thought I’d uncommented all the right lines, but I only got the ones that were commented at the beginning of the line. Works great, thank you so much!

  2. Mario says:

    Hello Vasil,

    I actually need the Calendar IDs. Does this script also allow to add the Calendar ID?

    Kind regards,
    Mario

    Reply
    1. Vasil Michev says:

      Not sure what you mean by IDs. In general you can easily modify the script to add any additional property exposed by Get-MailboxFolderStatistics

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.