M365 Powershell

Microsoft 365 : Room rights for user

August 27, 2020

author:

Microsoft 365 : Room rights for user

Sometimes it’s useful to check the rights for the default user (or any other user) on room calendars. The easiest way to check this is to execute a powershell. Without proper naming convention you could also use :

Get-Mailbox -Filter {ResourceType -eq “Room”}

#requires -version 2
<#
.SYNOPSIS
    get the rights for the default user on room calendars
.DESCRIPTION
    get the rights for the default user on room calendars
.NOTES
  Version:        1.0
  Author:         Pascal Briner
  Creation Date:  20.07.2020
  Purpose/Change: Initial script development
#>

#---------------------------------------------------------[Initialisations]--------------------------------------------------------



#---------------------------------------------------------[Authentication]--------------------------------------------------------
# run scripts in authentication folder

#----------------------------------------------------------[Declarations]----------------------------------------------------------
$CurrentDate = get-date -format "yyyy-MM-dd-HH-mm"
$ExportFile = ("C:\temp\Rooms_rightsForDefaultUser_" + $CurrentDate + ".csv")
$User = "Default"
$Results = @()
$RoomIdentifier = "ROOM*"



#-----------------------------------------------------------[Functions]------------------------------------------------------------


#-----------------------------------------------------------[Execution]------------------------------------------------------------
Write-Host "Script execution started .." -ForegroundColor Yellow
$mbxs = Get-Mailbox -Resultsize unlimited |Where {($_.Name -like $RoomIdentifier) }
if($mbxs){ 
     Foreach($mbx in $mbxs){ 
        
        $Name = $mbx.DisplayName 
        $Alias = $mbx.Alias 
        $Perm = Get-MailboxFolderPermission "$($Alias):\calendar" -User $User


        Write-Host "Working on user : "$Name -ForegroundColor Yellow

         $Properties = @{
         pName = $Name
         pAlias = $Alias
         pFolder = $Perm.Identity
         pRights = $Perm.AccessRights
         pUser = $Perm.user
         }

         $Results += New-Object psobject -Property $Properties
    } 
    Write-Host "Building Export File ..." -ForegroundColor Blue
    $Results | Select-Object pName,pFolder,pAlias,pRights,pUser | Export-Csv -notypeinformation -Path $ExportFile
    Invoke-Item $ExportFile
    Write-Host "Script execution ended successfully" -ForegroundColor Yellow
} else{
        Write-Host "No mailbox found" -ForegroundColor Red
        Write-Host "Script execution ended with failure" -ForegroundColor Red
}

You need to be authenticated agains EXO to execute the script.

Leave a comment