#利用Outlook.Application之com物件
$objOutLook = new-object -com Outlook.Application;
$objNamespace = $objOutLook.GetNamespace("MAPI");
$Contacts = $objNamespace.GetDefaultFolder("10").Items;
[string]$List=""
foreach($Contact in $Contacts)
{
#比對生日
if((get-date).day -eq [int]$Contact.Birthday.day -and (get-date).month -eq [int]$Contact.Birthday.month)
{
$List = $List + $Contact.FullName + " ";
}
}
(get-process outlook).kill();
if($List.length -gt 0)
{
#輸出本日壽星
out-host -inputobject ("Today is "+$List +"'s birthday!");
}
else
{
#本日無壽星
out-host -inputobject "nobody~"
}
全站熱搜
留言列表