Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following documentation describes how to create all desks at once in Office365.

For doing this, a CSV file must be provided as data source. This file will be used as input for a PowerShell script which will create all the desks in Office365 with a specific configuration.

Data Source (.csv file)

The list of desk must be provided in a CSV file. This file must contain for each desk the Name and the Alias.

The Name is how the resource will be displayed in Office365. The name in ROOMZ will/could be a different one.

The Alias is used for the identification of the desk.

A suggestion for the Alias: WorkspaceType.CountryCode.City.BuildingName.Floor.Zone.Id


The CSV file must be named input.csv and will looks the following. Please note that the separator must be ';'

Code Block
Name;Alias
Desk CH Fribourg BlueFactory 2.1.5;desk.ch.fribourg.bluefactory.2.1.5
Desk CH Zuerich Tower 0.3.4;desk.ch.zuerich.tower.0.3.4

PowerShell creation script

The following PowerShell script will read as input the file input.csv which must be in the same folder as the PowerShell script.

It will create the Desk (New-MailBox), then modifying the information stored in the Agenda of the desk during a booking request (Set-CalendarProcessing) and finally hide the desk from the address book (Set-MailBox) so that the resource will only be known in ROOMZ. 

Code Block
$Desks = Import-Csv -Path .\input.csv -Delimiter ';'
$DeskCreated = 0
$DeskError = 0
Write-Host "CSV file contains $($Desks.Length) desks"

for ($i = 0; $i -lt $Desks.Length; $i++) {
	$currentDesk = $Desks[$i]
	
	Try {
		Write-Host -NoNewLine "Creating '$($currentDesk.Name)' ($($currentDesk.Alias))"
		$noOutput = New-MailBox -room -name $currentDesk.Name -alias $currentDesk.Alias -resourcecapacity 1 -ErrorAction Stop

		$deskConfigured = $false
		Do {
			Try
			{
				Set-CalendarProcessing $currentDesk.Alias -AddOrganizerToSubject $false -DeleteSubject $false -RemovePrivateProperty $false -ErrorAction Stop
				Set-MailBox $currentDesk.Alias -HiddenFromAddressListsEnabled $true -ErrorAction Stop
				$deskConfigured = $true
			}
			Catch {
				Start-Sleep -s 5
				Write-Host -NoNewLine " ..."
			}
		} Until ($deskConfigured)

		Write-Host " done!" -ForegroundColor Green
		$DeskCreated++
	}
	Catch {
		Write-Error "Error while creating desk '$($currentDesk.Name)', Error: $($_.Exception.Message)" 
		$DeskError++
	}
}

Write-Host
Write-Host "Summary"
Write-Host "--------"

if ($DeskCreated -ne 0) {
	Write-Host "$($DeskCreated) desk(s) created successfully" -ForegroundColor Green
}
if ($DeskError -ne 0) {
	Write-Host "$($DeskError) desk(s) not created due to mentioned errors" -ForegroundColor Red
}