question

Sop-3080 avatar image
0 Votes"
Sop-3080 asked IanXue-MSFT edited

how to get members of OU.

I'm trying to find the last modified date for AdUser attribute. I can get the result for a single ADUser by running the following command:

Get-ADReplicationAttributeMetadata -Object (Get-AdUser User1) -Server DC1.mydomain.com | Where-Object {$_.AttributeName -eq "proxyAddresses"} | Select-Object -Property AttributeName,AttributeValue,FirstOriginatingCreateTime,LastOriginatingChangeTime,LastOriginatingChangeDirectoryServerIdentity

What I would like some help with will be, how I can run the above commands on an OU members and get the output for all of my users.

How would I go about it ?

Thanks,

windows-serverwindows-server-powershell
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 AndreasBaumgarten edited

Hi @Safs-3080 ,

maybe this is helpful to get startet (not tested by myself):

 $Users = Get-ADUser -Filter * -SearchBase "OU=ALLTESTUSERS,DC=MYDOMAIN,DC=COM"
 foreach ($User in $Users) {
 Get-ADReplicationAttributeMetadata -Object $User -Server DC1.mydomain.com |
  Where-Object {$_.AttributeName -eq "proxyAddresses"} |
   Select-Object -Property AttributeName,AttributeValue,FirstOriginatingCreateTime,LastOriginatingChangeTime,LastOriginatingChangeDirectoryServerIdentity
 }


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

Regards
Andreas Baumgarten


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.

Sop-3080 avatar image
0 Votes"
Sop-3080 answered IanXue-MSFT edited

Hello,

when run your above suggestion I get the following error:

at line: 1 Char:114............($Users in $Users)... unexpected token 'in' in expression or statement.

· 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.

It should be ($User in $Users), not ($Users in $Users).

0 Votes 0 ·