【问题标题】:Exchange script. Нow to add to the end of all lines交换脚本。 Н现在添加到所有行的末尾
【发布时间】:2020-08-14 03:21:01
【问题描述】:

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”的方法 提前非常感谢您!

【问题讨论】:

    标签: string powershell exchange-server


    【解决方案1】:

    想通了

    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 !

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-28
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多