Powershell get-aduser extensionattribute12

$name="d4rkcell"
Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAttribute12

I use the code above, but the result shows more than just extensionAttribute12, it shows other information, such as:

DistinguishedName    : CN=d4rkcell,OU=Users,...DC=co,DC=uk
Enabled              : True
extensionAttribute12 : \\path\to\a\share
GivenName            : Joe
Name                 : U0023883
ObjectClass          : user
ObjectGUID           : a0562e97-cb58-463b-bae6-8e0087fa494b
SamAccountName       : d4rkcell
SID                  : S-1-5-21-1004336368-1374586140-1801574631-62475
Surname              : Bloggs
UserPrincipalName    : J.Bloggs@....co.uk

Ideally, I would just like to keep the value stored in extensionAttribute12, can someone help me here or help me split this line? Bit stuck, help would be much appreciated.

+4
source share
2 answers

The parameter -Properties Get-ADUserseems a bit wrong. According to the documentation :

The properties

. , .

, , , . , :

$name="d4rkcell"
Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAttribute12 |
Select-Object -ExpandProperty extensionAttribute12

, , , "Get-ADUser" , :

(Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAttribute12).extensionAttribute12
+2

extensionAttribute12, :

Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAttribute12 | Select extensionAttribute12 
0

All Articles