Skip to content

Instantly share code, notes, and snippets.

@sob
Created August 19, 2020 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sob/ba7e300bc6988399a4b5566222439dff to your computer and use it in GitHub Desktop.
Save sob/ba7e300bc6988399a4b5566222439dff to your computer and use it in GitHub Desktop.
Import-Module MSOnline
Import-Module AzureAD
Import-Module ExchangeOnlineManagement
$mailboxList = Import-Csv -Path '.\mailboxes.csv'
function CountDown() {
param($timeSpan)
while($timeSpan -gt 0) {
Write-Host '.' -NoNewline
$timeSpan = $timeSpan - 1
Start-Sleep -Seconds 1
}
}
ForEach ($mailbox in $mailboxList) {
Write-Host -NoNewline "Processing mailboxes ["
Write-Host -NoNewLine -ForegroundColor Yellow $mailbox.UserPrincipalName
Write-Host "]..."
Write-Host -NoNewline " provisioning mailbox as room..."
New-Mailbox -Name $mailbox.Username -Alias $mailbox.Username -Room -DisplayName $mailbox.DisplayName -EnableRoomMailboxAccount $true -MicrosoftOnlineServicesID $mailbox.UserPrincipalName -RoomMailboxPassword (ConvertTo-SecureString -String $mailbox.Password -AsPlainText -Force) | Out-Null
Write-Host -ForegroundColor Green " done!"
Write-Host -NoNewline " configuring mailbox..."
Set-CalendarProcessing -Identity $mailbox.username -AutomateProcessing AutoAccept -AddOrganizerToSubject $false -DeleteComments $false -DeleteSubject $false -RemovePrivateProperty $false -AddAdditionalResponse $true -AdditionalResponse "This is a Teams Meeting room!" -BookingWindowInDays 365 -OrganizerInfo $true
Write-Host -ForegroundColor Green " done!"
Write-Host -NoNewline " setting password not to expire"
Set-MsolUser -UserPrincipalName $mailbox.UserPrincipalName -PasswordNeverExpires $true
Write-Host -ForegroundColor Green " done!"
Write-Host -NoNewline " setting the usage location"
Set-MsolUser -UserPrincipalName $mailbox.UserPrincipalName -UsageLocation US
Write-Host -ForegroundColor Green " done!"
Write-Host -NoNewline " configuring the license for the mailbox..."
Set-MsolUserLicense -UserPrincipalName $mailbox.UserPrincipalName -AddLicenses "corpuschristisaints:MEETING_ROOM_FACULTY"
Write-Host -ForegroundColor Green " done!"
}
Write-Host -NoNewline "Waiting 2 minutes to configure TEAMS settings..."
CountDown -timeSpan 120
ForEach ($mailbox in $mailboxList) {
Write-Host -NoNewline "Processing TEAMS settings ["
Write-Host -NoNewLine -ForegroundColor Yellow $mailbox.UserPrincipalName
Write-Host "]..."
Write-Host -NoNewline " configuring Teams Registration Pool..."
$pool = Get-CsOnlineUser -Identity $mailbox.UserPrincipalName | Select -ExpandProperty RegistrarPool -First 1
Enable-CsMeetingRoom -Identity $mailbox.UserPrincipalName -RegistrarPool $pool -SipAddressType EmailAddress -WarningAction SilentlyContinue
Write-Host -ForegroundColor Green " done!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment