anden3 icon

OutlookTasks.ps1

anden3 | PRO | 11/03/16 04:36:41 PM UTC | 0 ⭐ | 328 👁️ | Never ⏰ | []
PowerShell |

440 B

|

None

|

0 👍

/

0 👎

Add-Type -AssemblyName Microsoft.Office.Interop.Outlook
 
$folders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
$outlook = New-Object -ComObject Outlook.Application
$mapi = $outlook.GetNameSpace("mapi")
$tasks = $mapi.getDefaultFolder($folders::olFolderTasks)
 
$currentTime = Get-Date
 
foreach ($task in $tasks.Items) {
    if ($task.DueDate -lt $currentTime) {
        $task.Complete = true
        $task.Save()
    }
}

Comments