Powershell 每种语言的passwordLastSet和password很快过期,然后发送电子邮件
今天我的想法是提取一些密码即将过期的用户,然后用每种语言发送一封电子邮件Powershell 每种语言的passwordLastSet和password很快过期,然后发送电子邮件,powershell,exchange-server,Powershell,Exchange Server,今天我的想法是提取一些密码即将过期的用户,然后用每种语言发送一封电子邮件 $files=(Get-ChildItem "$HOME\script\expire\").FullName $send=@{ to = "administrator@corp.internal" from = "administrator@corp.internal" Subject = "US" Attachment = $files SmtpServer = "10
$files=(Get-ChildItem "$HOME\script\expire\").FullName
$send=@{
to = "administrator@corp.internal"
from = "administrator@corp.internal"
Subject = "US"
Attachment = $files
SmtpServer = "10.10.10.10"
}
$French=@{
to = "administrator@corp.internal"
from = "administrator@corp.internal"
Subject = "FR"
Attachments = $files
SmtpServer = "10.10.10.10"}
$AU=@{
to = "administrator@corp.internal"
from = "administrator@corp.internal"
Subject = "AU"
Attachments = $files
SmtpServer = "10.10.10.10"}
Get-AdUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False -and PasswordLastSet -gt 0 } -Verbose -Properties DisplayName, PasswordLastSet, Mail, Office -SearchBase "OU=Test,OU=CORP,DC=corp,DC=internal" -Server "10.10.10.1" | Where-Object {
$_.PasswordLastSet.AddDays(30).Date -eq ((Get-Date).AddDays(30).Date)
} |ForEach-Object -Verbose {
$bodyreset=
@"
I delete real message because it was to big and I don't have any issue to receive these mail
"@
if ( $_.office -like "FR*")
{
Send-MailMessage -Body "$bodyreset" -BodyAsHtml @french
}elseif($_.office -like "US*")
{
Send-MailMessage -Body "$bodyreset" -BodyAsHtml @send
}
else{
Send-MailMessage -Body "$bodyreset" -BodyAsHtml @AU
}
}
我在虚拟服务器上拥有29000个用户,该用户是在同一天创建的
我期待一些帮助来理解为什么脚本没有发送29000封电子邮件,事实上我收到了大约14000封电子邮件
在同一地址发送了14885封邮件后,我看到了这个错误
Send-MailMessage : Service not available, closing transmission channel. The server response was: 4.4.1 Connection timed out
At line:82 char:3
+ Send-MailMessage -Body "$bodyreset" -BodyAsHtml @AU
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
Send-MailMessage : Service not available, closing transmission channel. The server response was: 4.4.1 Connection timed out
At line:82 char:3
+ Send-MailMessage -Body "$bodyreset" -BodyAsHtml @AU
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
我尝试以CSV文件导出,我可以看到29000个用户,谢谢。count
你能帮我理解一下,我错在哪里。你不认为邮件服务器管理员可能设置了费率限制来阻止人们做你想做的事情:让邮件充斥整个系统吗?尝试增加延迟,或者至少以较小的脉冲发送邮件。或者与您的邮件管理员讨论将发送主机列入白名单的问题。我是这两台服务器的所有者,没有启用安全性,但我会检查。我发现你是对的。我从来没有考虑过microsoft exchange的安全性,因为我从Active Directory服务器发送邮件。我将尝试通过以下
If(((获取内容“$HOME\testc.txt”).count)-eq“10000”){write“breaks”sleep-Seconds 380}
我尝试存储在$t=@@@$t+=“a
n”`但不适用于count