How to get expand output for powershell cmdlet get-adtrust?

The powershell command get-aduser outputs a result similar to

DistinguishedName : CN=kw.k.com,CN=System,DC=my,DC=kw,DC=k,DC=com
Name : kw.k.com
ObjectClass : trustedDomain
ObjectGuid : 4bbec03e-b031-4b54-9d6c-2e3e812b6e66
PropertyNames : {Direction, DisallowTransivity, DistinguishedName, ForestTransitive, IntraForest, IsTreeParent, IsTreeRoot, Name, ObjectClass, ObjectGUID, SelectiveAuthentication, SIDFilteringForestAware, SIDFilteringQuarantined, Source, Target, TGTDelegation, TrustAttributes, TrustedPolicy, TrustingPolicy, TrustType, UplevelOnly, UsesAESKeys, UsesRC4Encryption}
AddedProperties : {}
RemovedProperties : {}
ModifiedProperties : {}
PropertyCount : 23

I would like to view the values for each property in 'PropertyNames'. How can this be achieved ?

1

1 Answer

You can get and or expand properties to get there values in a few ways. This is a well-documented use case, and not specific to this cmdlet. What iRon shows and the below depending on how much you need to see.

Try...

Dot referencing

Microsoft Docs | PowerShell Help files : About Properties

Property values

Although every object of a specific type has the same properties, the values of those properties describe the particular object. For example, every FileInfo object has a CreationTime property, but the value of that property differs for each file.

The most common way to get the values of the properties of an object is to use the dot method. Type a reference to the object, such as a variable that contains the object, or a command that gets the object. Then, type a dot (.) followed by the property name.

(Get-ADTrust -Identity 'corp.contoso.com').PropertyNames

Or using Select-Object and expanding collection properties

Get-ADTrust -Identity 'corp.contoso.com' |
Select-Object -ExpandProperty PropertyNames
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like