none
How to get the decimal value from PR_NORMAL_MESSAGE_SIZE_EXTENDED property with EWS API RRS feed

  • Question

  • Hi

    I currently use PowerShell and the EWS API to find and manage mailboxes for complex tasks

    I am now hoping to add the folder size value but have found that the PR_MESSAGE_SIZE_EXTENDED value that seems to be commonly used, does not match the foldersize value returned when using the get-mailboxfolderstatistics command. However, the PR_NORMAL_MESSAGE_SIZE_EXTENDED Decimal value does match, but I can't seem to find a method of extracting it. 

    I've tried setting the value to 26291 or 0x66B3 which I believe are correct, but this simply returns the value for PR_MESSAGE_SIZE_EXTENDED

    $PR_NORMAL_MESSAGE_SIZE_EXTENDED = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(26291, [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Integer)

    $PR_NORMAL_MESSAGE_SIZE_EXTENDED = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x66B3, [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::integer)

    Has someone managed to do this or know the process/MapiPropertyType I should be using?

    This is the script I have put together from a few online forums, any suggestions would be very helpful

    $psPropset= new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
    $PR_NORMAL_MESSAGE_SIZE_EXTENDED = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x66B3, [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::integer)

    $psPropset.add($PR_NORMAL_MESSAGE_SIZE_EXTENDED)
    $service.ImpersonatedUserId = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $EmailAddress)

    $RootFolderName = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,$EmailAddress)
    $RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service,$RootFolderName,$psPropset)

    $FolderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1000)
    $FolderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
    $Folderview.Propertyset = $psPropset


    $FoldersInView = $RootFolder.FindFolders($FolderView)

    foreach ($FolderFound in $FoldersInView) 
    {
        $fldObject = "" | select FolderName,FolderSize
        $folderSize = $null
        $FolderFound.TryGetProperty($PR_NORMAL_MESSAGE_SIZE_EXTENDED, [ref]$folderSize)
        write-host $FolderFound.DisplayName
        $FSize = [int]$folderSize
        write-host $FSize -fore yellow
    }


    Thanks

    Kev

    Thursday, July 11, 2019 2:58 AM

Answers