I'm trying to retain the Microsoft.ActiveDirectory.Management.ADAccount
object when searching and specifying return outputs; however, when selecting the outputs, additional fields are populating. Questions:
- Why is this is happening?
- Is there a method, command, or filter to return only the specified parameters? (not the extra fields listed in the example below)
- Is there a way to remove properties from the ADAccount Object? ($a in this example)
- For the select method, is there a way to retain the original object formatting ? (I do not want a table and still need to reference the object later)
Running the following command:
$a = Get-ADUser $targetPerson -Properties Department, EmailAddress, Office, OfficePhone
returns:
Department : **** DistinguishedName : CN=1111,OU=2222,OU=3333,OU=4444,DC=5555,DC=6666 EmailAddress : ****@mail.com Enabled : **** GivenName : **** Name : **** ObjectClass : user ObjectGUID : **** Office : **** OfficePhone : **** SamAccountName : **** SID : **** Surname : **** UserPrincipalName : ****