【发布时间】:2020-12-21 22:34:58
【问题描述】:
我的变量有问题。我想把它放在电子邮件的内容中,不幸的是所有尝试都以失败告终。在 Powershell 这是我的第一个脚本,我有编程经验。我想在电子邮件的内容中添加 $PasswordTillExpired 变量:
$emailBody = @"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
</head>
<body>
<b><p>Your password will expire soon! $PasswordTillExpired</p></b>
<p>Please change password at xxx password reset'</a> or contact Helpdesk.</p>
<p><br>More information about changing your password and instructions can be found</p></b>
<p>Greetings,</p>
<p>Helpdesk IT</p>
</body>
</html>
"@
【问题讨论】:
-
它对我来说很好,你确定你为变量分配了正确的值吗?
-
是的,只有这个变量在后面的循环中定义,所以你不要“更新”电子邮件内容。
标签: powershell powershell-2.0 powershell-3.0