none
Cannot cast variable as Microsoft.Exchange.WebServices.Data.FindItemsResults`1 RRS feed

  • Question

  • Hi,

    I

    'm trying to write a PowerShell script to query an Exchange mailbox. Every attempt I make to cast the type of an inbox search results as nullable of type

    "Microsoft.Exchange.WebServices.Data.FindItemsResults" I keep on getting an error about "Microsoft.Exchange.WebServices.Data.FindItemsResults" assembly type not found. Is there a way I can get my casting statement to work?

    Thx

    [void][Reflection.Assembly]::LoadFile("c:\temp\Microsoft.Exchange.WebServices.dll")

    # Connect to the Exchange service

    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)

    $service.Url = [System.URI]$SERVICEURI

    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()

    $aceUser = [ADSI]("LDAP://<SID=" + $windowsIdentity.user.Value + ">")

    $inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox)

    $view = New-Object Microsoft.Exchange.WebServices.Data.ItemView($inbox.TotalCount)

    [Microsoft.Exchange.WebServices.Data.FindItemsResults`1]$results = $inbox.FindItems($view)


    IT Support/Everything

    Friday, May 24, 2013 9:16 PM

All replies