excal-arights/utils/functions.ps1

53 lines
1.8 KiB
PowerShell
Raw Normal View History

<##
# EXCAL-ARIGHTS - utilities function
#
# @version 1.0.0
# @since 08-25-2022
#
# @author Jérémi Nihart <contact@endmove.eu>
# @copyright © 2022 EndMove, All rights reserved.
#
# @link https://git.endmove.eu/EndMove/excal-arights
#>
# Show a question dialog (yes/no)
Function DialogAsk {
param (
[string]$Title,
[string]$Message
)
$MsgBoxInput = [System.Windows.MessageBox]::Show($Message, $Title, 'YesNo', 'Question')
if ($MsgBoxInput -eq 'Yes') {Return $true} else {Return $false}
}
# Show an information dialog
Function DialogSay {
param (
[string]$Title,
[string]$Message
)
[System.Windows.MessageBox]::Show($Message, $Title, 'OK', 'Information')
}
# Show current permissions for all calandars and users
Function DisplayAll {
param (
[string[]]$CalandarFolders
)
$Users = Get-EXOMailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox
Write-Host ("[$ScriptName] We found " + $Users.count + " users") -BackgroundColor White -ForegroundColor Black
foreach ($User in $Users) {
Write-Host $User.Name -BackgroundColor DarkGreen
$Calandars = Get-EXOMailboxFolderStatistics $User.Identity -FolderScope Calendar | Where-Object {$_.Name -in $CalandarFolders}
foreach ($Calandar in $Calandars) {
Write-Host $Calandar.Name.ToString() -BackgroundColor DarkMagenta
$CurrCalId = $User.Identity.ToString() + ":\" + $Calandar.Name.ToString()
$CurrCalPerms = Get-MailboxFolderPermission -Identity $CurrCalId
foreach ($CurrCalPerm in $CurrCalPerms) {
Write-Host ($CurrCalPerm.User.ToString() +" : " + $CurrCalPerm.AccessRights)
}
}
Write-Host
}
}