0

私は次のものを持っています:

{
$matches[0]

$url = $matches[0]

$wc = new-object system.net.WebClient

$result = Invoke-WebRequest $url

$newresult = $result.Content -replace "`n",""

}

$olFolderInbox = 6
$outlook = new-object -com outlook.application;
$ns = $outlook.GetNameSpace("MAPI");
$inbox = $ns.GetDefaultFolder($olFolderInbox)

$targetfolder = $inbox.Folders | where-object { $_.name -eq "Backup" }

$targetfolder.items | where-object { $_.body -match "\bhttps://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-    9+&@#/%=~_|$]" } | % {$matches[0]}

フォルダー内の電子メールの本文で、URL の例の電子メールの本文を検索します。

fred is good https://1.1.1.1:1111/fred. 

現在のスクリプトは、一致する本文ごとに一致のリストを返します。

私がやろうとしているのは、 % {$matches[0]} 部分を関数 fred に渡すことですが、次のように変更すると、最後の一致のみが渡され、すべてではないように見えます。

$targetfolder.items | where-object { $_.body -match "\bhttps://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-    9+&@#/%=~_|$]" } | fred $matches[0]

ありがとう?

4

1 に答える 1