I might be asking this in the wrong place so I apologize. I'm running a PS1 file to look in a specific folder, mark the emails as read, save the attachments and send me an email. For whatever reason, marking the emails as read, doesn't always work.
Since everything else works perfectly, I'll leave you with just what is not working
#Open Outlook and find emails from today
$ol = New-Object -ComObject Outlook.Application
$ns = $ol.GetNamespace('mapi')
$mb = $ns.Stores['some@email.com'].GetRootFolder()
$inbox = $mb.Folders['Reports']
$inbox.Items | ForEach-Object {$_.UnRead = $false}
If I run the script in ISE one line at a time, it works.
The problem arises when I select all and run in ISE, or as a PS1
Thanks!