使用PowerShell列出对象说明 [英] Using PowerShell to list Object Description
问题描述
我有一个CSV文件,其中包含我域中PC的列表。我想从AD中获取AD中列出的每台计算机的描述字段信息。这是我到目前为止的内容:
I have a CSV file with a list of PC's in my domain. I wanted to get the "Description" Field information from AD for each of the machines listed in AD. This is what I have so far:
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中,并过滤出说明字段,甚至从何处开始。
I am not sure where I need to add in the get-ADObject and filter out the Description Field or even where to begin on that. Any help would be awesome!
谢谢!
推荐答案
您当前仅输出以下属性:Name,OperatingSystem,CanonicalName到CVS。如果将描述添加到要选择的对象列表中,那么您也应该也获得描述属性。
You are currently only outputting the following properties: Name,OperatingSystem,CanonicalName to your CVS. If you add Description to the list of objects your are selecting you should also get the Description properties too.
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:
I did my testing using the following though, it returned the name, Description, OperatingSystem and CanonicalName of all of the machines on my domain:
Import-Module ActiveDirectory
Get-ADComputer -Filter * -Properties * | Select-object name,Description,OperatingSystem,CanonicalName | Export-Csv C:\PCList.csv -NoTypeInformation
您可能会发现此网站很有用,我几乎总能在ss64上找到有关powershell问题的答案
You might find this website useful, I can almost always find answers to my powershell questions on ss64
这篇关于使用PowerShell列出对象说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!