powershellpowershell-1.0

Get-ADComputer, some -Properties not showing up in Format-Table


I am gathering a list of all computers on my domain and trying to display some specific properties in a formatted table. This is the command I'm using:

Get-ADComputer `
-Filter "objectclass -eq 'computer'" `
-SearchBase "DC=JHanDomain,DC=local" `
-Properties info | FT Name,Enabled,whenCreated,whenChanged,DistinguishedName -A

The code runs without error and displays a nicely formatted table, but the data in the 'whenCreated' and 'whenChanged' columns are missing.

It shows up fine when I just do -Properties whenChanged,whenCreated but not when I try to format it into a table. Any idea why this might be?


Solution

  • Whichever additional properties you need to display outside of default ones, need to be added to the -Properties list, so in your case whenCreated,whenChanged, I removed info, since you were not displaying it. You could also use * instead if you still choosing all the properties

    Get-ADComputer `
    -Filter "objectclass -eq 'computer'" `
    -SearchBase "DC=JHanDomain,DC=local" `
    -Properties whenCreated,whenChanged | FT Name,Enabled,whenCreated,whenChanged,DistinguishedName -A
    

    From Get-ADComputer help:

       -Properties string[]
           The properties of the output object to retrieve from the server.
           Use this parameter to retrieve properties that are not included in the default set.
            
           Specify properties for this parameter as a comma-separated list of names.
           To display all of the attributes that are set on the object, use *
    
           To specify an individual extended property, use the name of the property.
           For properties that are not default or extended properties, specify the LDAP provider name.