从导入 CSV 文件获取 AD 组注释和描述字段
我正在尝试导入包含多个 AD 组的 .csv 文件,并且我只想获取注释和说明字段。我目前遇到错误,并且不确定我做错了什么。任何帮助将不胜感激。
$ADGroups = import-csv "C:\Users\User\Documents\ADNotesField.csv"
foreach ($ADGroup in $ADGroups)
{ Get-ADGroup -Identity $ADGroup -Properties info, description
}
$ADGroup | Export-CSV -Path "C:\Users\User\Documents.csv" -NoTypeInformation
这是我收到的错误:
Get-ADGroup : Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADGroup' required by parameter 'Identity'. Specified method is not supported.
At line:3 char:25
+ { Get-ADGroup -identity $ADGroups -Properties info, description
+ ~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ADGroup], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.GetADGroup
CSV 文件前几行从单元格 A1 开始,一直到 A2,等等。所有这些都是 AD 组:
Domain Users
Washington Techs
California Techs
Nevada Techs
I'm trying to import a .csv file that contains multiple AD groups and I want to get only the notes and Description field. I'm currently getting errors, and I'm not sure what I'm doing incorrectly. Any help will be appreciated.
$ADGroups = import-csv "C:\Users\User\Documents\ADNotesField.csv"
foreach ($ADGroup in $ADGroups)
{ Get-ADGroup -Identity $ADGroup -Properties info, description
}
$ADGroup | Export-CSV -Path "C:\Users\User\Documents.csv" -NoTypeInformation
This is the error that I'm receiving:
Get-ADGroup : Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADGroup' required by parameter 'Identity'. Specified method is not supported.
At line:3 char:25
+ { Get-ADGroup -identity $ADGroups -Properties info, description
+ ~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ADGroup], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.GetADGroup
CSV File first few lines starting at cell A1 and going down to A2, etc. All of these are AD Groups:
Domain Users
Washington Techs
California Techs
Nevada Techs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确实有 CSV(逗号分隔)并且考虑到
Users
列包含您需要查询的 AD 组,则以下操作应该有效:If you really have a CSV (comma-delimited) and considering the
Users
column has the AD Groups you need to query, the following should work: