0
votes

Silly question that I can't quite locate solution.

Trying to list all property names of Get-ADUser and Get-ADComputer so that I can load the property list in a combobox of a dialog for selections to run a report. For example;

AccountExpirationDate:, accountExpires:, AccountLockoutTime:, AccountNotDelegated:, AllowReversiblePasswordEncryption:, AuthenticationPolicy:, AuthenticationPolicySilo:, BadLogonCount:, c:, CannotChangePassword:, CanonicalName:, Certificates:, City:, CN:, co:, codePage:, Company:, CompoundIdentitySupported:, Country:, countryCode:, Created:, createTimeStamp:, Deleted:, Department:, Description:, DisplayName:, DistinguishedName:, Division:, DoesNotRequirePreAuth:, dSCorePropagationData:, EmailAddress:, EmployeeID:, EmployeeNumber:, employeeType:, Enabled:, extensionAttribute1:, extensionAttribute4:, extensionAttribute5:, Fax:, GivenName:, HomeDirectory:, HomedirRequired:, HomeDrive:, HomePage:, HomePhone:, Initials:, instanceType:, ipPhone:, isDeleted:, KerberosEncryptionType:, l:, language:, LastBadPasswordAttempt:, LastKnownParent:, lastLogon:, LastLogonDate:, lastLogonTimestamp:, LockedOut:, logonCount:, LogonWorkstations:, mail:, Manager:, MemberOf:, MNSLogonAccount:, MobilePhone:, Modified:, modifyTimeStamp:, msDS-User-Account-Control-Computed:, msNPAllowDialin:, msRTCSIP-DeploymentLocator:, msRTCSIP-FederationEnabled:, msRTCSIP-InternetAccessEnabled:, msRTCSIP-OptionFlags:, msRTCSIP-PrimaryHomeServer:, msRTCSIP-PrimaryUserAddress:, msRTCSIP-UserEnabled:, msRTCSIP-UserPolicies:, msRTCSIP-UserPolicy:, msRTCSIP-UserRoutingGroupId:, Name:, nTSecurityDescriptor:, ObjectCategory:, ObjectClass:, ObjectGUID:, objectSid:, Office:, OfficePhone:, Organization:, OtherName:, PasswordExpired:, PasswordLastSet:, PasswordNeverExpires:, PasswordNotRequired:, physicalDeliveryOfficeName:, POBox:, PostalCode:, preferredLanguage:, PrimaryGroup:, primaryGroupID:, PrincipalsAllowedToDelegateToAccount:, ProfilePath:, ProtectedFromAccidentalDeletion:, proxyAddresses:, pwdLastSet:, SamAccountName:, sAMAccountType:, ScriptPath:, sDRightsEffective:, ServicePrincipalNames:, SID:, SIDHistory:, SmartcardLogonRequired:, sn:, st:, State:, StreetAddress:, Surname:, telephoneNumber:, Title:, TrustedForDelegation:, TrustedToAuthForDelegation:, url:, UseDESKeyOnly:, userAccountControl:, userCertificate:, userParameters:, UserPrincipalName:, uSNChanged:, uSNCreated:, whenChanged:, whenCreated:, wWWHomePage:

3
Please edit your question to make it more readable. - TobyU

3 Answers

1
votes

One way to List all properties of Get-ADUser

Get-ADUser -Properties * -Filter * | Get-Member

and the same for Get-ADComputer

Get-ADComputer -Properties * -Filter * | Get-Member
1
votes

You're also able to grab just the fields you need from AD from a particular OU rather than iterating through the entirety of your AD.

Changing any of the label = "some text" will change the name on the exported csv.

This makes reuse really convenient if you're having to call the same data more than once.

Import-Module Activedirectory

$Data=@(                  
Get-ADUser  -Filter {Enabled -eq $true} -SearchBase “ou=User Accounts,ou=UserAccounts,dc=hiscox,dc=com” -Properties EmailAddress, extensionattribute2 |  
Select-Object @{Label = "First Name";Expression = {$_.GivenName}}, @{Name = "Last Name";Expression = {$_.Surname}}, @{Name = "Email";Expression = {$_.EmailAddress}}, @{Name = "Business Area";Expression = {$_.extensionattribute2}}
        )

$Data | Export-Csv -Path c:\adusers.csv -NoTypeInformation      
0
votes
Get-ADUser | gm | where MemberType -eq property