Exchange Web服务(EWS) - 约会资源

时间:2017-06-12 20:50:42

标签: powershell exchangewebservices

我设法使用EWS命令行创建了一个模拟帐户。

但我希望将一个房间(Exchange Room Mailbox)作为资源/位置。

在我的脚本中,我添加了以下两个命令行:

  • $NewAppointment.Location($RoomName)
  • $NewAppointment.Resources.Add($RoomMail)
$RoomName $RoomMail 可以通过 Get-MailBox 命令行找到:

  • $Room = Get-MailBox $CSV.Room
  • $RoomName = $Room.DisplayName
  • $RoomMail = $Room.UserPrincipalName or $Room.PrimarySmtpAddress

编辑:

我添加了以下代码块:

$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是一个功能:

function newGuid() { return [guid]::NewGuid() }

错误是:

  

为" ExtendedPropertyDefinition"找到了多个模糊的重载。和参数计数:" 3"。

1 个答案:

答案 0 :(得分:0)

您只需要在创建约会后使用Load()重新加载约会,然后您应该看到这些属性已填写完毕。这些信息在创建约会时会自动生成,而不会在CreateItem操作中返回,因此赢得了#39 ; t出现,直到你发出另一个GetItem请求。

修改

您需要使用扩展属性添加此信息,因为EWS不会为您执行此操作,例如

        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, "Somewhere@domain.com");
        newapt.SetExtendedProperty(LocationSource, 5);
        newapt.SetExtendedProperty(LocationDisplayName, "Somewhere");

编辑2 powershell代码

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