I have a question on Powershell. What I'm trying to do is looping through the inbox of a shared (group) mailbox, if the e-mail comes from a set of 2 sender names then save the CSV Attachments to a specific folder and then move the e-mail to another sub-folder of inbox.
I managed this morning to make it work for the loop-save attachment part on one sender's name, but then somehow broke the code (on the first foreach loop). Plus, I am not able to run the "move e-mail" part.

Here's the code I got:

```
#define outlook object and ask to pick folder
$outlook = New-Object -comobject outlook.application
$mapi = $outlook.GetNamespace("MAPI")
$fldr = $mapi.PickFolder()
$DestFolder = "\\MAIBOXNAME\Inbox\01.Reports"
#use i as counter to define filenumber to save PendingOrders
$i = 1
$fldr.Items| foreach  {$fldr.Items.Sender.Name -like "Name1" - or $fldr.Items.Sender.Name -like "Name2"
    $year = $fldr.Items.ReceivedTime.ToString("yyyy")
    $month = $fldr.Items.ReceivedTime.ToString("MM")
    $fdate = $fldr.Items.ReceivedTime.ToString("yyyy.MM.dd")
    $fpath = "Path\02.Daily Files\" + $year + '\' + $year + '.' + $month + '\' + $fdate
    #loop through attachments to find CSV extension - if found, save file to target path with the counter in the name and update the counter
    $fldr.Items.Attachments|foreach {
        $_.Filename
        If ($_.filename.Contains("CSV")) {                    
            $fname = $_.filename           
            $_.saveasfile((Join-Path $fpath  "00$i $fname"))
            $i = $i + 1 
        }
    $_.Move($DestFolder)
    }
}

```

Could you please assist me in finalising this?

Thanks a lot!!