选择对象 - 属性返回某些大多数属性的空值 Powershell



我使用以下代码行从Active Directory获取计算机列表,然后将它们与某些属性一起导出到CSV文件。但是,只有"SamAccountName"和"DNSHostName"在CSV文件中返回值。所有其他属性均为空。

Get-ADComputer -filter * | Select-Object -Property SamAccountName,DNSHostName,PasswordLastSet,whenCreated,accountExpirationDate,operatingSystem,operatingSystemServicePack,operatingSystemVersion,userAccountControl,LastLogonDate |export-csv -path "C:Usersoutput.csv"

当我只选择属性"PasswordLastSet"时,CSV文件看起来很奇怪,只返回true和false,而不是日期和时间。例如,以下是前三行:

#TYPE Selected.Microsoft.ActiveDirectory.Management.ADComputer
enabled
TRUE

我处理这个问题的方式有什么问题吗?

ADComputer这样的AD对象有很多属性,默认情况下,出于性能原因,Get-ADComputer只检索其中的几个属性。使用 -properties 参数指定所需的属性。

Get-ADComputer -filter * -Properties SamAccountName,DNSHostName,PasswordLastSet,whenCreated,accountExpirationDate,operatingSystem,operatingSystemServicePack,operatingSystemVersion,userAccountControl,LastLogonDate 
  | Select-Object -Property SamAccountName,DNSHostName,PasswordLastSet,whenCreated,accountExpirationDate,operatingSystem,operatingSystemServicePack,operatingSystemVersion,userAccountControl,LastLogonDate 
  | export-csv -path "C:Usersoutput.csv"

使用 -属性 * 获取全部

最新更新