본문 바로가기
ICT

[PowerShell]Creating Room Mailbox As Resource

by NeoSailer 2023. 4. 7.

[Scenario]

Dear Chinese IT colleague asks to create a mailbox as resource to manage booking schedules of a meeting room

 

[Objectives]

Create two meeting room resource emailboxs with the given information below.

#1. CN Shanghai A1F Mtg Room

mailbox name:CN Shanghai A1F Mtg Room

email address:CNShanghai.A1FMtgRoom@rotork.com

 

#2. CN Shanghai B2F Small Mtg Room

mailbox name:CN Shanghai B2F Small Mtg Room

email address:CNShanghai.B2FSmallMtgRoom@rotork.com

 

[Steps]

Connect to ExchangeOnline and input admin. credential

Connect-ExchangeOnline

 

Create a new mail box by using "New-Mailbox" command

New-Mailbox "CN Shanghai A1F Mtg Room" -DisplayName "CN Shanghai A1F Mtg Room" -Room

 

Set mailbox address with "Set-Mailbox" command

Set-Mailbox "CN Shanghai A1F Mtg Room" -EmailAddresses SMTP:CNShanghai.A1FMtgRoom@rotork.com

 

Check mailbox information whether a mailbox is created as intended with "Get-Mailbox" command

Get-Mailbox "CN Shanghai A1F Mtg Room" | format-list name,recipientTypeDetails,PrimarySmtpAddress


Name                 : CN Shanghai A1F Mtg Room
RecipientTypeDetails : RoomMailbox
PrimarySmtpAddress   : CNShanghai.A1FMtgRoom@rotork.com

 

Repeate those steps for "CN Shanghai B2F Small Mtg Room"

 


 

For the future use, below is a function to create a room resource mailbox.

function createResourceRoom{
    param([string]$name
          ,[string]$address
    )
    #connection check    
    $rtn = Get-ConnectionInformation | where Name -like "Exchange*" | Select-object Name -ErrorAction Stop
    if($rtn -eq $null)
    {
        Write-Host "No ExchangeOnline Session Found"
        return
    }

    #checking whether the same name/email address exists
    ##name
    $rtn = Get-Mailbox $name
    if($rtn -ne $null)
    {
        Write-Host "Mailbox name already exist: "$name
        return
    }

    ##address
    $rtn = Get-Mailbox $address
    if($rtn -ne $null)
    {
        Write-Host "Mailbox name already exist: "$address
        return
    }

    #create new mailbox
    New-Mailbox $name -DisplayName $name -Room
    #set email address
    Set-Mailbox $name -EmailAddresses SMTP:$address    
}

 

반응형

'ICT' 카테고리의 다른 글

[PowerShell]Moving Computers from OSD Folder  (0) 2023.04.24
[PowerShell]Resetting User Password  (0) 2023.04.12
[PowerShell]Setting Mailbox Autoreply  (0) 2023.04.06
[PowerShell]Creating Email Distribution Group  (0) 2023.04.04
[PowerShell]7. Functions  (0) 2023.04.03

댓글