I managed to create an appointment to an impersonate account with EWS command-lines.
But I want to include a room (Exchange Room Mailbox) as Resource / Location.
In my script I've added the two command-lines below :
$NewAppointment.Location($RoomName)
$NewAppointment.Resources.Add($RoomMail)
$RoomName
and $RoomMail
are found by the Get-MailBox
command-lines :
$Room = Get-MailBox $CSV.Room
$RoomName = $Room.DisplayName
$RoomMail = $Room.UserPrincipalName or $Room.PrimarySmtpAddress
Edit :
I've added the following block of code :
$NewGuid = newGuid
$LocationURIGuid = $NewGuid.Guid
$LocationURI = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition($LocationURIGuid, "LocationUri", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String)
$NewAppointment.SetExtendedProperty($LocationURI,$RoomMail)
$NewGuid = newGuid
$LocationSourceGuid = $NewGuid.Guid
$LocationSource = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition($LocationSourceGuid, "LocationSource", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Integer)
$NewAppointment.SetExtendedProperty($LocationSource,5)
$NewGuid = newGuid
$LocationDisplayNameGuid = $NewGuid.Guid
$LocationDisplayName = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition($LocationSourceGuid, "LocationDisplayName", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Integer)
$NewAppointment.SetExtendedProperty($LocationDisplayName,$Room)
newGuid is a function :
function newGuid() { return [guid]::NewGuid() }
The error is :
Multiple ambiguous overloads found for "ExtendedPropertyDefinition" and the argument count: "3".