powershell - 使用Powershell在每行的开头添加文本

标签 powershell

我正在使用Powershell将用户导出到CSV。一切正常,但我想将Live @ edu的命令添加到每一行以进行导入。我要添加的文本是每行之前的“添加,邮箱”。可以在export-csv之前完成吗?提前致谢。

这是导出代码:

$CSV = @()
get-qaduser -searchroot 'OU=Test Live,DC=domain,DC=edu' -sizelimit 0 | foreach-object {
    $attributes = get-qaduser $_ | Select-Object Name,Mail,givenName,sn,displayName
    $CSV += $attributes
}
$CSV | export-csv -path "c:\test.csv" -encoding unicode -notypeinformation

最佳答案

尝试此操作,它将为每个用户对象添加两个新列(属性),Action(添加)和Resource(邮箱):

Get-QADUser -SearchRoot 'OU=Test Live,DC=domain,DC=edu' -SizeLimit 0 | Select-Object @{Name='Action';Expression='Add'}},@{Name='Resource';Expression='Mailbox'}},Name,Email,GivenName,LastName,DisplayName | Export-Csv -Path c:\test.csv -Encoding Unicode -NoTypeInformation

关于powershell - 使用Powershell在每行的开头添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6850799/

相关文章:

powershell - 如何搜索 PowerShell Get-Help 条目?

powershell - 是否可以在 PowerShell 中的 bool[] 中包含 [Nullable[bool]]

windows - 有没有办法使用powershell点击应用程序中的按钮

azure - 如何使用 Powershell 在 Azure API 管理中禁用订阅 key

windows - 是否有一种编程方式来确定支持哪些应用程序处理器架构?

跨版本的 PowerShell 安装文件夹和脚本文件扩展名

powershell - Powershell-VirtualBox克隆脚本错误

Powershell:将参数传递给作业

windows - pdftk update_info 命令发出我不明白的警告

google-chrome - PowerShell,如何在现有的浏览器选项卡中打开URL?