【问题标题】:Using PowerShell to list Object Description使用 PowerShell 列出对象描述
【发布时间】:2016-07-17 11:37:03
【问题描述】:

我有一个 CSV 文件,其中包含我域中的 PC 列表。我想从 AD 中获取 AD 中列出的每台机器的“描述”字段信息。这是我目前所拥有的:

Import-Module ActiveDirectory

Get-ADComputer -Filter {OperatingSystem -NotLike "*Server*"} -SearchBase "OU=Active,OU=Regular Computers,OU=EPComputers,DC=epenergy,DC=net" -Properties * | Select-Object Name,OperatingSystem,CanonicalName | Export-Csv C:\PCList.csv -NoTypeInformation

我不确定我需要在哪里添加 get-ADObject 并过滤掉描述字段,甚至从哪里开始。任何帮助都会很棒!

谢谢!

【问题讨论】:

    标签: csv active-directory field-description


    【解决方案1】:

    您目前仅向 CVS 输出以下属性:Name、OperatingSystem、CanonicalName。如果您将描述添加到您选择的对象列表中,您还应该获得描述属性。

    Select-Object Name,OperatingSystem,CanonicalName,Description
    

    这将使您的代码块:

    Import-Module ActiveDirectory
    
    Get-ADComputer -Filter {OperatingSystem -NotLike "*Server*"} -SearchBase "OU=Active,OU=Regular Computers,OU=EPComputers,DC=epenergy,DC=net" -Properties * | Select-Object Name,OperatingSystem,CanonicalName,Description | Export-Csv C:\PCList.csv -NoTypeInformation
    

    我使用以下内容进行了测试,它返回了我域中所有机器的名称、描述、操作系统和 CanonicalName:

    Import-Module ActiveDirectory
    
    Get-ADComputer -Filter * -Properties * | Select-object name,Description,OperatingSystem,CanonicalName | Export-Csv C:\PCList.csv -NoTypeInformation
    

    您可能会发现this website 很有用,我几乎总能在 ss64 上找到我的 powershell 问题的答案

    【讨论】:

      猜你喜欢
      • 2020-08-26
      • 2020-08-12
      • 2019-09-03
      • 2017-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-27
      • 2011-02-21
      相关资源
      最近更新 更多