问题
Is there a way by which I can retrieve a list of AD's only belonging to a particular "City"?
Because, there is a property in SET-ADuser -city, so there must be a way for the reverse also!
回答1:
The "City" field is mapped to an LDAP attribute called "Locality-Name". The LDAP Display Name for said property is l (that's a lowercase L):
Get-ADUser "mwood" -Properties l | Select-Object Name,@{Name="City";Expression={$_.l}}
It also seems that Get-ADUser is able to do the translation itself, so you can use a filter like:
Get-ADUser -Filter "City -eq 'CityName'"
You could also use an LDAP filter:
Get-ADUser -LDAPFilter "(&(l=CityName)(!(HomeDirectory=*)))"
回答2:
Get-ADUser -Filter "*" -Properties City | Where-Object {$_.City -eq "Dublin"}
or
Get-ADUser -Filter "City -eq 'Dublin'"
let me know if either of these work for you
来源:https://stackoverflow.com/questions/31872720/retrieve-users-with-same-city-through-get-aduser