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