Adding Resource Customs to Room-mailbox

This topic contains 1 reply, has 2 voices, and was last updated by  Jannifer Lisa 1 year, 7 months ago.

  • Author
  • #6531

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


    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)

    $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)
    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:

    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 + ""
    $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
    # Settings for room mailbox
    New-Mailbox -Name $roomName -Alias $roomName -OrganizationalUnit '' -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)
    $roomEquipment += ","
    $roomEquipment += $room

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

    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)

    Set-Mailbox -ResourceCustom $ResourceMailbox.ResourceCustom.Add

  • #54895

    Jannifer Lisa

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

You must be logged in to reply to this topic.