0
votes

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".

1

1 Answers

0
votes

You just need to use Load() to reload the appointment once you have created it and then you should see those properties filled out.That information is popualted when the appointment is created and not returned in the CreateItem operation so won't appear until you make another GetItem request.

Edit

You need to add this information using Extended properties as EWS won't do it for you eg

        Guid PropGuid = Guid.Parse("{A719E259-2A9A-4FB8-BAB3-3A9F02970E4B}");
        ExtendedPropertyDefinition LocationURI = new ExtendedPropertyDefinition(PropGuid, "LocationUri", MapiPropertyType.String);
        ExtendedPropertyDefinition LocationSource = new ExtendedPropertyDefinition(PropGuid, "LocationSource", MapiPropertyType.Integer);
        ExtendedPropertyDefinition LocationDisplayName = new ExtendedPropertyDefinition(PropGuid, "LocationDisplayName", MapiPropertyType.String);
        newapt.SetExtendedProperty(LocationURI, "[email protected]");
        newapt.SetExtendedProperty(LocationSource, 5);
        newapt.SetExtendedProperty(LocationDisplayName, "Somewhere");

Edit 2 powershell code

$PropGuid = [Guid]::Parse("{A719E259-2A9A-4FB8-BAB3-3A9F02970E4B}")
    $LocationURI = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition($PropGuid, "LocationUri", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String)
    $NewAppointment.SetExtendedProperty($LocationURI,$RoomMail)

    $LocationSource = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition($PropGuid, "LocationSource", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Integer)
    $NewAppointment.SetExtendedProperty($LocationSource,5)

    $LocationDisplayName = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition($PropGuid, "LocationDisplayName", 

    [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Integer)
    $NewAppointment.SetExtendedProperty($LocationDisplayName,$Room)