我已经整理了一个PS脚本,该脚本从AD组获取值并将它们放入电子邮件中发送给我们的服务台。我遇到的问题是AD组中的值是在一个数组中,但我无法弄清楚如何在单独的行上显示这些值。下面是我使用AD组和三个测试用户的代码:
$members = @(Get-qADGroupMember adgroup -IncludedProperties "DisplayName,sAMAccountName")
$smtp = "smtpserver.domain.com"
$to = "helpdesk@domain.com"
$from = "security@domain.com"
$subject = "Accounts Disabled"
$body = "Helpdesk, `n `n"
$body += "These users have had their passwords reset and their accounts disabled. There is no action required on the part of IT helpdesk, this is strictly to notify you. These users will probably be calling soon: `n `n"
$body += For ($i=0; $i -lt $members.Length; $i++) {
$members[$i -join "`n"]
}
$body += "`n"
$body += "For any questions regarding this, please contact the Information Security Team `n `n"
$body += "Thank you `n"
$body += "Information Security"
这是输出:
服务台,
这些用户已重置密码及其帐户。 IT服务台不需要采取任何措施,严格来说是通知您。这些用户可能很快就会打电话:
domain \ testuser1 domain \ testuser2 domain \ testuser3 如有任何疑问,请联系信息安全小组
谢谢 信息安全
如何让该组中的用户像这样在自己的行上显示?
域\ testuser1
域\ testuser2
域\ testuser3
答案 0 :(得分:1)
你过度工作了。 PowerShell喜欢写行。既然你已经在这里有一个数组,你可以简单地添加它。
$(document).ready(function() {
$('a.gallery').colorbox();
});
在发送之前,您只需要将其转换为字符串。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.6.4/jquery.colorbox-min.js"></script>
<a class='gallery' href='http://www.telegraph.co.uk/content/dam/Travel/galleries/travel/hubs/thebigpicture/the-big-picture-photography-competition-round-393/Fary-Afshar-xlarge.jpg'>photo</a>