我有以下Powershell脚本:
$outlook = new-object -com Outlook.Application
$sentMail = $outlook.Session.GetDefaultFolder(6) # == olFolderSentMail
$sentMail.folders.item("FDA UFMS User Provision").Items | %{ $RESULT=[Regex]::Match($_.TaskSubject ,"Request\s\d{6}"); if($RESULT.Success){$RESULT.Value}} | %{$Result=[regex]::Match($_,"\d{6}"); if($RESULT.Success){$RESULT.Value}} |
Out-File C:\Temp\Powershell_6_digit_Codes.txt -Append
但是,它不会从FDA UFMS User Provision
文件夹中获取数据,因为它与收件箱位于同一级别(不在收件箱中)。
如何更改$sentMail.folders.item("FDA UFMS User Provision").Items
的脚本以便获取此数据?
到目前为止我试过
$sentMail.item("FDA UFMS User Provision").Items
但是没有产生正确的结果。
谢谢!
答案 0 :(得分:0)
这有效:
$outlook = new-object -com Outlook.Application
$sentMail = $outlook.Session.GetDefaultFolder(6) # == olFolderSentMail
$bigFolder = $sentMail.Parent
$ufms = "FDA UFMS User Provision"
$newufms = $bigFolder.folders.item($ufms)
$newufms.Items | %{ $RESULT=[Regex]::Match($_.TaskSubject, "Request\s\d{6}"); if ($RESULT.Success)
{$RESULT.Value}} | %{$Result=[Regex]::Match($_, "\d{6}"); if($RESULT.Success){$RESULT.Value}} | Out-File C:\Temp
\Powershell_6_digit_Codes.txt -Append