Author Posts

January 1, 2012 at 12:00 am

by Christer at 2013-03-11 04:18:38

Hey.

Occasionally I have to create new Room mailboxes. To make this easier I want to create a script to automatically set all settings for each new room.

I got most of it working, except adding resource customs to my rooms.

My code accepts input from user, and checks it against an array I've created to contains all room resources:
$roomResource = @("Videokonferanse", "Laserutstyr", "Gjestekontor", "TV", "PC", "Projektor", "Flipover", "Wifi", "Whiteboard")

If it matches it will add the resource to a string($equipment)

example
$equipment = "TV,PC,Whiteboard"

I then want to add everything inside the string as a resource custom my room.

$ResourceMailbox = Get-Mailbox -Identity $romNavn ($romnavn is input from the user)
$ResourceMailbox.ResourceCustom.Add($equipment)
Set-Mailbox -ResourceCustom $ResourceMailbox.ResourceCustom.Add

I aslo tried only adding one value in $equipment

Still wont work..

Anyone know why?

Error message:

Cannot process argument transformation on parameter 'ResourceCustom'. Cannot convert value "System.Void Add(string item
)" to type "Microsoft.Exchange.Data.MultiValuedProperty`1[System.String]". Error: "Conversion from System.Management.Au
tomation.PSObject to System.String has not been implemented."
+ CategoryInfo : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox

by Christer at 2013-03-11 05:48:04

I've rewritted the script to english, so I can post full version:

cls
Import-Module ActiveDirectory

# Create an array of your meetingroom resources

$roomResource = @("Videokonferanse", "Laserutstyr", "Gjestekontor", "TV", "PC", "Projektor", "Flipover", "Wifi", "Whiteboard")

## Variables ##

$roomName = Read-Host "Enter room name"
$userPrincipal = $roomName + "@testlabb.ad"
$office = Read-Host "Office location(In full name, ex: Porsgrunn)"
$capacity = Read-Host "Enter room capacity"
$resources = Read-Host "Room resources:ex(Videokonferanse, Laserutstyr, Gjestekontor, TV, PC, Projektor, Flipover, Wifi, Whiteboard)"
$resourcesArray = $resources.Split(",")
$resourcesTrimmed = ForEach($verdi in $resourcesArray){$verdi.Trim()}

# Create funtion
Function createRoom
{
[cmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$roomName,
[Parameter(Mandatory=$True)]
[string]$office,
[Parameter(Mandatory=$True)]
[string]$capacity
)
# Settings for room mailbox
New-Mailbox -Name $roomName -Alias $roomName -OrganizationalUnit 'testlabb.ad/Exchange/Rom' -UserPrincipalName $userPrincipal -SamAccountName $roomName -FirstName $roomName -Initials '' -LastName '' -Room
Set-CalendarProcessing -Identity $roomName -AutomateProcessing AutoAccept -BookingWindowInDays 365 -AddOrganizerToSubject $false -DeleteSubject $false
Set-Mailbox -Identity $roomName -ResourceCapacity $capacity

$roomEquipment = ""
ForEach($room in $roomResource)
{
ForEach($arrayItem in $resourcesTrimmed)
{

if($arrayItem -eq $room)
{
If($roomEquipment)
{
$roomEquipment += ","
}
$roomEquipment += $room
}
}
}

$roomEquipmentArray = $roomEquipment.Split(",")
$ResourceMailbox = Get-Mailbox -Identity $roomName
ForEach($equipment in $roomEquipmentArray)
{
$ResourceMailbox.ResourceCustom.Add($equipment)
}

Set-Mailbox -ResourceCustom $ResourceMailbox.ResourceCustom.Add

#Set Office location
$user = Get-ADUser -Identity $roomName
Set-ADUser -Identity $user.SamAccountName -Office $office

}

# Run Function
createRoom -roomName $roomName -office $office -capacity $capacity

This is the part I'm having trouble with:

ForEach($equipment in $roomEquipmentArray)
{
$ResourceMailbox.ResourceCustom.Add($equipment)
}

Set-Mailbox -ResourceCustom $ResourceMailbox.ResourceCustom.Add

October 4, 2016 at 10:36 am

Best interactive whiteboard on the market at the lowest cost, information and communication technologies (ICT) by experts. interaktívna tabuľa