I want to fetch all attributes like only Attributes that have Values (like ADUC). Just I am able to getting attributes names. Also , I want to get all attributes together with values like below.
Script :
$ADUser = Get-ADUser -Identity 'user' -Properties *
$CusUser = New-Object -TypeName PSObject
$ADUser.PropertyNames | ?{$ADUser.$_ -ne $null} | %{ $CusUser | Add-Member -MemberType NoteProperty -Name $_ -Value $ADUser.$_ }
Output:
AccountExpirationDate
accountExpires
AccountLockoutTime
AccountNotDelegated
AllowReversiblePasswordEncryption
AuthenticationPolicy
AuthenticationPolicySilo
BadLogonCount
CannotChangePassword
CanonicalName
Certificates
City
CN
..
..
blah
blah
My desired output:
AccountExpirationDate blank
accountExpires ; never
AccountLockoutTime ; blank
AccountNotDelegated ; blank
AllowReversiblePasswordEncryption ; blank
AuthenticationPolicy ; blank
AuthenticationPolicySilo ; blank
BadLogonCount ; blank
CannotChangePassword ; blank
Certificates ; blank
City ; blank
CN ; john T
..
..
blah
blah