首页 > 解决方案 > 交换脚本。Н现在添加到所有行的末尾

问题描述

powershell.exe -Nologo -NonInteractive -WindowStyle Hidden -NoProfile -command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer mx.company.org; ". 'Set-ADServerSettings -ViewEntireForest $true; Get-Mailbox -Server mx | select -expand EmailAddresses | %{$_.SmtpAddress} > C:\temp\1.txt ; Get-DistributionGroup -DomainController 'dc.company.org' | select -expand EmailAddresses | %{$_.SmtpAddress} >> C:\temp\1.txt '""

将列表写入 1.txt,其中仅列电子邮件将打印在表单中

abc@company.ru
bac@company.ru
..

现在我想要实现的是在每一行附加“OK”,这样我得到以下信息:

abc@company.ru OK
bac@company.ru OK
..

我真的不熟悉 PowerShell,也没有找到添加“OK”的方法,非常感谢您!

标签: stringpowershellexchange-server

解决方案


想通了

PowerShell.exe -Command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer mx.company.org; C:\temp\email-list.ps1"

C:\temp\email-list.ps1:

Set-ADServerSettings -ViewEntireForest $true; Get-Mailbox -Server mx | select -expand EmailAddresses | %{$_.SmtpAddress +" OK"} > C:\temp\1.txt ; Get-DistributionGroup -DomainController 'dc.company.org' | select -expand EmailAddresses | %{$_.SmtpAddress +" OK"} >> C:\temp\1.txt

谢谢 2 全部!


推荐阅读