question

Ozz-4746 avatar image
0 Votes"
Ozz-4746 asked Ozz-4746 commented

A script to return the value of extension attribute 9 in a specific OU

Hello,

I am searching for a PowerShell script that will return the value of extension attribute 9 in a specific OU in active Directory. Could someone assist me with this?

Thanks!

azure-active-directorywindows-server-powershellwindows-active-directory
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered Ozz-4746 commented

Hi @Ozz-4746 ,

please try this:

 $ou = "OU=Whatever,DC=MYDomain,DC=local"
 Get-ADUser -Filter * -SearchBase $ou -Properties extensionattribute9 | Select-Object -ExpandProperty extensionattribute9


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This is brilliant it outputs the licenses for all users in the OU. You are super! Thank you very much. I have one more request, is it possible to add a line of code so that it also outputs the display name next to the license aswell?

That would be perfect!

0 Votes 0 ·
AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered Ozz-4746 commented

Hi @Ozz-4746 ,

are you talking about the extensionattribute9 of AD users in a specific OU in your domain?

Than may this helps to get started (not tested by myself):

 $ou = "OU=Whatever,DC=MYDomain,DC=local"
 Get-ADUser -SearchBase $ou -Properties extensionattribute9


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Andreas,


I've tried your script but I get the error


Message: 'Operator Not supported: =' at position: '5'.
At line:1 char:2
+ Get-ADUser -SearchBase $ou -Properties extensionattribute9
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (:) [Get-ADUser], ADFilterParsingException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADFilterParsingException,Micr
osoft.ActiveDirectory.Management.Commands.GetADUser






$ou = "OU=Users,OU=XXX,OU=XXXX,DC=XXX,DC=AXXX,DC=XXX"
Get-ADUser -SearchBase $ou -Properties extensionattribute9

0 Votes 0 ·