我想通过名为Distribution Point的列对html结果进行排序。我该怎么做呢?
foreach ($result in $results)
{
if ($sccmContent | where-object { $_.PackageID -eq $result.PackageID })
{
$package = $sccmContent | where-object { $_.PackageID -eq $result.PackageID }
$packageSize = $([math]::Round($package.PackageSize/1024, 2))
$packageSizeUnit = "MB"
if ($packageSize -gt 1000)
{
$packageSize = $([math]::Round($packageSize/1024, 2))
$packageSizeUnit = "GB"
}
}
$failure = New-Object PSObject
$failure | Add-Member -Type NoteProperty -Name 'ContentType' -Value $package.__CLASS.Replace('SMS_', '')
$failure | Add-Member -Type NoteProperty -Name 'PackageID' -Value $result.PackageID
$failure | Add-Member -Type NoteProperty -Name 'DistributionPoint' -Value $result.ServerNALPath.split('\\')[2].split('.')[0]
$failure | Add-Member -Type NoteProperty -Name 'PackageName' -Value $package.Name
$failure | Add-Member -Type NoteProperty -Name 'PackageSize' -Value "$($packageSize) $($packageSizeUnit)"
$failure | Add-Member -Type NoteProperty -Name 'LastFailure' -Value $([System.Management.ManagementDateTimeConverter]::todatetime($result.SummaryDate))
$failures += $failure
}
$failures | ft
if ($failures)
{
#HTML Email Style
$style = "<style>BODY{font-family: Calibri; font-size: 11pt;}"
$style += "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style += "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style += "TD{border: 1px solid black; padding: 5px; }"
$style += "</style>"
$body = "<html><font face='Calibri' size='10pt'>"
$body += "The following packages have failed to distribute to the specified Distribution Points:<br /><br />"
$body += $failures | ConvertTo-Html -head $style
$body += "<br /><br />"
Send-MailMessage -smtpserver $smtpserver -from $from -to $to -subject "SCCM Content Distribution Failures" -body $body -bodyashtml
}
答案 0 :(得分:1)
您可以使用<button class="btn2 btn-primary btn-lg dropdown-toggle" type="button" id="WebPast" data-toggle="dropdown">
<a href= "HomePage.html">
Home Page ▼ </a>
</button>
cmdlet执行此操作。对于您的特定代码,您可以更改此行:
Sort-Object
要:
$body += $failures | ConvertTo-Html -head $style