2017-06-12 104 views
0

我設法使用EWS命令行創建一個模擬帳戶的約會。Exchange Web Services(EWS) - 任命資源

但我想包括一個房間(Exchange Room Mailbox)作爲資源/位置。

在我的劇本我已經添加下面的兩個命令行:

  • $NewAppointment.Location($RoomName)
  • $NewAppointment.Resources.Add($RoomMail)

$RoomName$RoomMailGet-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() } 

的錯誤是: 「3」:發現 「ExtendedPropertyDefinition」 和參數計數

多曖昧重載。

回答

0

你只需要使用load()來重新加載預約,一旦你已經創建了它,那麼你應該看到的是創建約會時,那些充滿out.That信息的屬性被popualted和createItem操作,不返回如此直到你發出另一個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, "[email protected]"); 
     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) 
+0

謝謝您的回答此信息。 事實是Load()或不是我添加的房間不像房間。 在命令行或web應用程序中,位置始終顯示爲地址。 – NivekLR

+0

您可以在您的問題中添加一些說明,因爲您沒有給出足夠的細節或代碼供任何人回答 –

+0

好。對不起:) 當我想創建一個會議/約會作爲資源/位置與房間模擬帳戶我使用$ NewAppointment.Resources.Add($房間)命令行。這個命令添加一個資源,但是這個不是真實的房間。 Outlook OWA上的結果是位置條目顯示爲經典位置(Bing搜索),而不是像房間。 – NivekLR

相關問題