title: Accessing Outlook Folder in PowerShell 5
body: <p>I wrote a script in PS 4 that would read the contents of an Outlook folder, find unread emails, process them, then move them into another folder.  This script worked great until PS 5 was pushed to my workstation. Now, I get the following error:</p>
  
  <blockquote>
  <pre><code>Error while invoking [PROPERTYGET, DISPID(0)]. Could not find member.
  At U:\Powershell\Scripts\Outlook - Process Emails.ps1:214 char:7
  +     $($folger.Items)[$i].Subject
  +       ~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : OperationStopped: (:) [], MissingMemberException
      + FullyQualifiedErrorId : System.MissingMemberException
  </code></pre>
  </blockquote>
  
  <p>Here's the main block of code:</p>
  
  <pre><code>Add-Type -assembly "Microsoft.Office.Interop.Outlook"
  $Outlook = New-Object -ComObject Outlook.Application
  $NameSpace = $Outlook.GetNameSpace("MAPI")
  
  $folder = $NameSpace.Folders.Item("Scans").Folders.Item("Results")
  
  for ($i = ($folder.Items.Count - 1); $i -ge 0; $i--)
  {
      if ($($folder.Items)[$i].UnRead) # It breaks on this line
      {
          # Do stuff
      }
  }
  </code></pre>
  
  <p>Two questions:</p>
  
  <p>1) What changed between PS 4 and PS 5 to cause this?  Nothing jumped out in the release notes for PS 5.</p>
  
  <p>2) What can I do to get my script back up and running w/o issue?</p>