我必须做错事,结果是空的,我尝试用PsObject
转换html,它需要-Append
创建多个html表,不适合发送电子邮件,任何帮助表示赞赏。
Foreach($sender in $senders){
$users=Get-TransportServer|Get-MessageTrackingLog -Start (Get-Date).AddHours(-4) -ResultSize Unlimited -Sender $sender.PrimarySmtpAddress |?{$_.Recipients -notlike "*@domain.us" -and $_.RecipientCount -eq "1" -and $_.RecipientStatus -notlike "*,*" -and $_.eventid -eq 'RECEIVE' }
}
$users | % {
$t = New-Object PSObject -Property @{
Sender = $_.Sender
Receiver = $_.Recipients
Messagesubject=$_.Messagesubject
RecipientCount =$_.RecipientCount
TimeStamp=$_.TimeStamp
}
$outtbl += $t
}
$outtbl
答案 0 :(得分:1)
为什么需要$users
,$outtbl
或$t
?
foreach ( $sender in $senders ) {
Get-TransportServer |
Get-MessageTrackingLog -Start (Get-Date).AddHours(-4) -ResultSize Unlimited -Sender $sender.PrimarySmtpAddress |
Where-Object { ($_.Recipients -notlike "*@domain.us") -and
($_.RecipientCount -eq 1) -and
($_.RecipientStatus -notlike "*,*") -and
($_.eventid -eq 'RECEIVE') } | ForEach-Object {
[PSCustomObject] @{
Sender = $_.Sender
Receipients = $_.Recipients
MessageSubject = $_.MessageSubject
RecipientCount = $_.RecipientCount
TimeStamp = $_.TimeStamp
}
}
}
(未经测试 - 这只是如何消除不必要的变量并编写更清晰的代码的示例。)
此代码示例需要PowerShell 3.0或更高版本,因为它使用[PSCustomObject]
。
答案 1 :(得分:0)
这是它
^(?:[01][0-9]?[0-9]?|2[0-4][0-9]|25[0-5])(?:\.0{1,3}){3}$