New-RoomMailboxSetup.ps1
|
<#PSScriptInfo
.VERSION 1.0.0 .GUID 0a99ab3e-bd37-503b-a1d6-67b14e945df8 .AUTHOR Torsten Weise .COMPANYNAME powerscripting.de .COPYRIGHT (c) 2026 Torsten Weise. MIT-Lizenz. .TAGS Powerscripting German Exchange ExchangeOnline Mailbox PSEdition_Desktop PSEdition_Core .LICENSEURI https://powerscripting.de/skripte/files/LICENSE.txt .PROJECTURI https://powerscripting.de/skripte/new-roommailboxsetup.html .ICONURI https://powerscripting.de/assets/icon-192.png .EXTERNALMODULEDEPENDENCIES Exchange Management Shell .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES Erste Veröffentlichung in der PowerShell Gallery. .PRIVATEDATA #> <# .SYNOPSIS Legt ein Raumpostfach an oder richtet ein bestehendes ein: automatische Annahme, Stellvertretung und Vollzugriff. .DESCRIPTION Erstellt bei Bedarf ein neues Raumpostfach und setzt die üblichen Einstellungen für Besprechungsräume: - Anfragen werden automatisch angenommen oder abgelehnt (AutoAccept) - Konflikte werden abgelehnt, auf Wunsch sind Serientermine mit einzelnen Konflikten erlaubt - Betreff und Organisator bleiben im Raumkalender sichtbar - Optional: Stellvertretung, die Anfragen außerhalb der Regeln freigibt - Optional: Vollzugriff für Verwalter - Optional: Kapazität und Raumliste Funktioniert in der Exchange Management Shell und in Exchange Online (Connect-ExchangeOnline). .PARAMETER Name Anzeigename des Raums, zum Beispiel "Besprechungsraum 1.OG". .PARAMETER Alias Alias und Anfang der Mailadresse. Standard: aus dem Namen abgeleitet. .PARAMETER Capacity Anzahl Plätze. .PARAMETER Delegate Benutzer, die als Stellvertretung Anfragen freigeben. .PARAMETER FullAccess Benutzer, die Vollzugriff auf das Raumpostfach bekommen. .PARAMETER RoomList Optional. Name einer Raumliste (Verteilergruppe vom Typ RoomList), in die der Raum aufgenommen wird. .EXAMPLE .\New-RoomMailboxSetup.ps1 -Name "Besprechungsraum 1.OG" -Capacity 8 -Delegate empfang@contoso.com .EXAMPLE .\New-RoomMailboxSetup.ps1 -Name "Konferenzraum" -Capacity 20 -FullAccess it-admin@contoso.com -RoomList "Räume Hamburg" -WhatIf .NOTES Autor: Torsten Weise, powerscripting.de #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [string] $Name, [string] $Alias = (($Name -replace '[^a-zA-Z0-9]', '').ToLower()), [int] $Capacity, [string[]] $Delegate, [string[]] $FullAccess, [string] $RoomList ) if (-not (Get-Command Set-CalendarProcessing -ErrorAction SilentlyContinue)) { throw 'Bitte zuerst die Exchange Management Shell öffnen oder Connect-ExchangeOnline ausführen.' } $mbx = Get-Mailbox -Identity $Alias -ErrorAction SilentlyContinue if (-not $mbx) { if ($PSCmdlet.ShouldProcess($Name, 'Raumpostfach anlegen')) { $mbx = New-Mailbox -Name $Name -Alias $Alias -Room Write-Host "Raumpostfach angelegt: $($mbx.PrimarySmtpAddress)" -ForegroundColor Green } } elseif ($mbx.RecipientTypeDetails -ne 'RoomMailbox') { throw "$Alias existiert bereits, ist aber kein Raumpostfach ($($mbx.RecipientTypeDetails))." } if (-not $mbx) { return } # -WhatIf beim Anlegen if ($Capacity -and $PSCmdlet.ShouldProcess($Name, "Kapazität $Capacity setzen")) { Set-Mailbox -Identity $mbx.Identity -ResourceCapacity $Capacity } $calendar = @{ Identity = $mbx.Identity AutomateProcessing = 'AutoAccept' AllowConflicts = $false AllowRecurringMeetings = $true DeleteSubject = $false AddOrganizerToSubject = $true RemovePrivateProperty = $false } if ($Delegate) { $calendar.ResourceDelegates = $Delegate } if ($PSCmdlet.ShouldProcess($Name, 'Kalenderverarbeitung einrichten')) { Set-CalendarProcessing @calendar } foreach ($u in $FullAccess) { if ($PSCmdlet.ShouldProcess($Name, "Vollzugriff für $u")) { Add-MailboxPermission -Identity $mbx.Identity -User $u -AccessRights FullAccess -InheritanceType All -AutoMapping $false | Out-Null } } if ($RoomList -and $PSCmdlet.ShouldProcess($RoomList, "$Name zur Raumliste hinzufügen")) { Add-DistributionGroupMember -Identity $RoomList -Member $mbx.Identity } Get-CalendarProcessing -Identity $mbx.Identity | Select-Object Identity, AutomateProcessing, AllowConflicts, ResourceDelegates |