<## # EXCAL-ARIGHTS - runable script (entrypoint) # # @version 1.0.0 # @since 08-25-2022 # # @author Jérémi Nihart # @copyright © 2022 EndMove, All rights reserved. # # @link https://git.endmove.eu/EndMove/excal-arights #> # Setup script $Root = (Split-Path $MyInvocation.MyCommand.Path -Parent) . $Root\configs.ps1 . $Root\utils\functions.ps1 Import-Module ExchangeOnlineManagement Add-Type -AssemblyName PresentationFramework # Start logging Start-Transcript -Path $Root\$LogFile -Append # Statistics variables $CountOK = 0 $CountUpdated = 0 $CountError = 0 # Initiate exchange connection Connect-ExchangeOnline -UserPrincipalName $AdminAccount -ShowProgress $true # Do you realy want to change permissions ? if ((DialogAsk "$ScriptName" "Do you want to continue and change the permission of the calendars according to your current configuration?") -eq $false) { Stop-Transcript Exit } # Retrieving users mailbox $Users = Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Where-Object {$_.Alias -notin $IgnoreAlias} Write-Host ("We found " + $Users.count + " users`n") -BackgroundColor White -ForegroundColor Black # Processing users mailbox list foreach ($User in $Users) { Write-Host $user.Name -BackgroundColor DarkBlue try { $Calandars = Get-MailboxFolderStatistics $User.Identity -FolderScope Calendar | Where-Object {$_.Name -in $CalandarFolders} # Process user calandars foreach ($Calandar in $Calandars) { $CurrCalId = $User.Identity.ToString() + ":\" + $Calandar.Name.ToString() $CurrCalPerm = Get-MailboxFolderPermission -Identity $CurrCalId -User Default } } catch { Write-Host "[ERROR] An unexpected error occured." -ForegroundColor DarkRed Write-Host "--> $_" -ForegroundColor DarkRed $CountError++ } Write-Host } # Showing resultats DialogSay "$ScriptName" "The update was performed successfuly.`n`n$CountOK account(s) was already correctly configured.`n$CountUpdated account(s) were updated.`n$CountError error(s) occurred." # Stop logging Stop-Transcript