string - 交换脚本。Н现在添加到所有行的末尾
问题描述
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”的方法,非常感谢您!
解决方案
想通了
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 全部!
推荐阅读
- reactjs - 创建 Docker 映像时,命令“npm install”以代码 9009 退出
- c# - IBM MQ 客户端开发环境测试
- r - 在 data.table 中,如何使用 j 中的 ifelse() 进行子集化,并使用 .N 作为子集后的观察数?
- r - R,在 if 语句中处理 NA 以创建新的二进制变量,只是删除 NA 不是一个选项
- php - Laravel 雄辩的如果它不存在如何创建关系?
- doctrine-orm - Doctrine 2 定义属性类型而不创建列
- r - R 限制 View() 表中的小数位
- openlayers - OpenLayers v6.3.1 两个位置之间的距离
- google-analytics - 跟踪 iOS 安装 - 适用于应用 + 网站的 Google Analytics(分析)属性 ID
- ios - 为什么我的 UIView 的 UILabel 子视图不显示?