title: Powershell - Outlook Mark all mails as read then delete
body: <p>having some problems trying to figure this one out.
  For some reason my script is not working as it should.</p>
  
  <p>It should mark all mails in inbox folder as read and then delete them.
  However, when the script runs it only delete's half of the .count $emails show...</p>
  
  <p>How to solve this, am I doing something wrong?</p>
  
  <pre><code>$outlook = new-object -comobject outlook.application
  
  #Define folders
  $namespace = $outlook.GetNameSpace("MAPI")
  $pst = $namespace.Stores
  $pstRoot = $pst.GetRootFolder()
  $pstFolders = $pstRoot.Folders
  #$personal = $pstFolders.Items("ARCHIVE")  ##Not working, sadly.
  $DefaultFolder = $namespace.GetDefaultFolder(6)
  $InboxFolders = $DefaultFolder.Folders
  $DeletedItems = $namespace.GetDefaultFolder(3)
  $Emails = $DefaultFolder.Items
  
  Foreach ($Email in $Emails) {
  #Define folders
  $Email.UnRead = $false
  $Email.Move($DeletedItems) | out-null
  continue
  }
  </code></pre>