gpt4 book ai didi

html - PowerShell 如何计算邮件中 html 表中的所有行

转载 作者:行者123 更新时间:2023-11-28 06:34:55 25 4
gpt4 key购买 nike

此 PowerShell 代码正在创建一个 html 表并发送一封邮件,其中包含表中显示的所有用户,但如何添加计数器。这样我就可以看到总行数。

这是我的代码:

$CurrentDate = Get-Date
$SubjectDate = $CurrentDate.ToString('yyyy-MM-dd')
$EmailFrom = "test@test.com"
$EmailTo = "test@test.com"
$EmailSubject = "Test mail " + $SubjectDate
$SMTP = "smtp.mail.com"
$Head = Get-Content "C:\path\css.txt"
$Footer = "<br><br> This report is a test <br> Generated on $CurrentDate "
$Body = Get-ADUser -Filter * -SearchBase "OU=Users,OU=SOME,OU=DOMAIN" -Properties * | Where { $_.enabled -ne $false } | Select Name | ConvertTo-Html -Head $Head -PostContent $Footer -As Table | Out-String
Send-MailMessage -to $EmailFrom -from $EmailTo -subject $EmailSubject -Body $Body -BodyAsHtml -SmtpServer $EmailServer

最佳答案

您可以像这样添加用户计数:

$Users = Get-ADUser -Filter * -SearchBase "OU=Users,OU=SOME,OU=DOMAIN" -Properties * | Where { $_.enabled -ne $false }
$Body = $Users | Select Name | ConvertTo-Html -Head $Head -PostContent $Footer -As Table | Out-String
Write-Host "Total Users: $($Users.Count)"
Send-MailMessage -to $EmailFrom -from $EmailTo -subject $EmailSubject -Body $Body -BodyAsHtml -SmtpServer $EmailServer

关于html - PowerShell 如何计算邮件中 html 表中的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34762954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com