2015-01-19 2 views
1

Я пытаюсь получить все встречи, существующие в календаре в общих папках организации, для целей отчетности.Получение общих календарей календарей с Exchange Powershell

Командлет Powershell Exchange 2010 Get-PublicFolderItemStatistics возвращает часть необходимой мне информации, но кажется, что возвращенные объекты не имеют некоторых свойств that should exist on the Appointment object, хотя я вижу их значения в назначении в Outlook (также 2010).

В частности, мне нужны свойства даты начала и окончания, которые возвращаются в исходное состояние.

Пример:

Get-PublicFolderItemStatistics -identity "\30 Day" | Sort-Object CreationTime | Format-List 

Возвращает:

ServerName   : EXCHANGE1 
DatabaseName   : Public Folder Database 167851469 
Subject    : Test 30 
PublicFolderName  : \30 Day 
LastModificationTime : 1/19/2015 3:05:05 PM 
CreationTime   : 1/19/2015 3:05:05 PM 
HasAttachments  : False 
ItemType    : IPM.Appointment 
MessageSize   : 5.47 KB (5,601 bytes) 
Identity    : (removed) 
MapiIdentity   : (removed) 
OriginatingServer : exchange1.mydomain.local 
IsValid    : True 
ObjectState   : Changed 

И:

Get-PublicFolderItemStatistics -identity "\30 Day" | Sort-Object CreationTime | Format-List Subject,CreationTime,Start,End 

Возвращает:

Subject  : Test 30 
CreationTime : 1/19/2015 3:05:05 PM 
Start  : 
End   : 

Однако назначение в Outlook, показывает время начала и окончания правильно:

Appointment in Outlook

Есть ли способ, чтобы получить эту информацию со стороны сервера? Я надеялся избежать взаимодействия с Outlook, если это возможно.

ответ

1

Этот командлет возвращает только ограниченное подмножество свойств объекта, если вам нужно что-то еще, что вам нужно, чтобы использовать клиентский API, такой как EWS или Outlook OOM, для доступа к общей папке и содержимому. Чтобы использовать клиентский API на папку, необходимо иметь права на эту папку, то вы можете использовать что-то подобное в EWS и Powershell

## Get the Mailbox to Access from the 1st commandline argument 

$MailboxName = $args[0] 

## Load Managed API dll 

###CHECK FOR EWS MANAGED API, IF PRESENT IMPORT THE HIGHEST VERSION EWS DLL, ELSE EXIT 
$EWSDLL = (($(Get-ItemProperty -ErrorAction SilentlyContinue -Path Registry::$(Get-ChildItem -ErrorAction SilentlyContinue -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Exchange\Web Services'|Sort-Object Name -Descending| Select-Object -First 1 -ExpandProperty Name)).'Install Directory') + "Microsoft.Exchange.WebServices.dll") 
if (Test-Path $EWSDLL) 
    { 
    Import-Module $EWSDLL 
    } 
else 
    { 
    "$(get-date -format yyyyMMddHHmmss):" 
    "This script requires the EWS Managed API 1.2 or later." 
    "Please download and install the current version of the EWS Managed API from" 
    "http://go.microsoft.com/fwlink/?LinkId=255472" 
    "" 
    "Exiting Script." 
    exit 
    } 

## Set Exchange Version 
$ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2 

## Create Exchange Service Object 
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($ExchangeVersion) 

## Set Credentials to use two options are availible Option1 to use explict credentials or Option 2 use the Default (logged On) credentials 

#Credentials Option 1 using UPN for the windows Account 
$psCred = Get-Credential 
$creds = New-Object System.Net.NetworkCredential($psCred.UserName.ToString(),$psCred.GetNetworkCredential().password.ToString()) 
$service.Credentials = $creds  

#Credentials Option 2 
#service.UseDefaultCredentials = $true 

## Choose to ignore any SSL Warning issues caused by Self Signed Certificates 

## Code From http://poshcode.org/624 
## Create a compilation environment 
$Provider=New-Object Microsoft.CSharp.CSharpCodeProvider 
$Compiler=$Provider.CreateCompiler() 
$Params=New-Object System.CodeDom.Compiler.CompilerParameters 
$Params.GenerateExecutable=$False 
$Params.GenerateInMemory=$True 
$Params.IncludeDebugInformation=$False 
$Params.ReferencedAssemblies.Add("System.DLL") | Out-Null 

[email protected]' 
    namespace Local.ToolkitExtensions.Net.CertificatePolicy{ 
    public class TrustAll : System.Net.ICertificatePolicy { 
     public TrustAll() { 
     } 
     public bool CheckValidationResult(System.Net.ServicePoint sp, 
     System.Security.Cryptography.X509Certificates.X509Certificate cert, 
     System.Net.WebRequest req, int problem) { 
     return true; 
     } 
    } 
    } 
'@ 
$TAResults=$Provider.CompileAssemblyFromSource($Params,$TASource) 
$TAAssembly=$TAResults.CompiledAssembly 

## We now create an instance of the TrustAll and attach it to the ServicePointManager 
$TrustAll=$TAAssembly.CreateInstance("Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll") 
[System.Net.ServicePointManager]::CertificatePolicy=$TrustAll 

## end code from http://poshcode.org/624 

## Set the URL of the CAS (Client Access Server) to use two options are availbe to use Autodiscover to find the CAS URL or Hardcode the CAS to use 

#CAS URL Option 1 Autodiscover 
$service.AutodiscoverUrl($MailboxName,{$true}) 
"Using CAS Server : " + $Service.url 

#CAS URL Option 2 Hardcoded 

#$uri=[system.URI] "https://casservername/ews/exchange.asmx" 
#$service.Url = $uri  

## Optional section for Exchange Impersonation 

#$service.ImpersonatedUserId = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $MailboxName) 

function FolderIdFromPath{ 
    param (
      $FolderPath = "$(throw 'Folder Path is a mandatory Parameter')" 
     ) 
    process{ 
     ## Find and Bind to Folder based on Path 
     #Define the path to search should be seperated with \ 
     $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::PublicFoldersRoot) 
     $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid) 
     #Split the Search path into an array 
     $fldArray = $FolderPath.Split("\") 
     #Loop through the Split Array and do a Search for each level of folder 
     for ($lint = 1; $lint -lt $fldArray.Length; $lint++) { 
      #Perform search based on the displayname of each folder level 
      $fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1) 
      $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$fldArray[$lint]) 
      $findFolderResults = $service.FindFolders($tfTargetFolder.Id,$SfSearchFilter,$fvFolderView) 
      if ($findFolderResults.TotalCount -gt 0){ 
       foreach($folder in $findFolderResults.Folders){ 
        $tfTargetFolder = $folder     
       } 
      } 
      else{ 
       "Error Folder Not Found" 
       return $null 
      }  
     } 
     if($tfTargetFolder -ne $null){ 
      return $tfTargetFolder.Id.UniqueId.ToString() 
     } 
    } 
} 
#Example use 
$fldId = FolderIdFromPath -FolderPath "\test\calendar" 
$SubFolderId = new-object Microsoft.Exchange.WebServices.Data.FolderId($fldId) 
$SubFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$SubFolderId) 
if($SubFolder -ne $null){ 
    #Define ItemView to retrive just 1000 Items  
    $ivItemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)  
    $fiItems = $null  
    do{  
     $fiItems = $service.FindItems($SubFolder.Id,$ivItemView)  
     #[Void]$service.LoadPropertiesForItems($fiItems,$psPropset) 
     foreach($Item in $fiItems.Items){  
        $Item.Subject + " " + $Item.Start  
     }  
     $ivItemView.Offset += $fiItems.Items.Count  
    }while($fiItems.MoreAvailable -eq $true) 
} 

Приветствие Глен

+0

Спасибо за образец, я дам EWS попробуйте завтра. – raney

Смежные вопросы