dsmod or other command to edit AD user attributes

2020-07-27 03:40发布

问题:

It does not appear that DSMOD has the capability to update this portion of a user's AD attributes (Street, P.O. Box, City, State, Zip). Are there any command line alternatives out there I can run from powershell or cmd?

Motivation: I'm trying to populate our entire roster with specific user info. I will also include phone numbers, and business information (title, company, department).

I have a roster spreadsheet with all this information, and I'd like to compose a command that will push all this info to AD for every user in the roster.

However, I cannot seem to find a command that will allow me to update the information found under the "Address" tab on the user attributes (if looking up the user from AD Users & Computers).

Hopefully someone knows of a better way!

回答1:

Not sure if this is still relevant as your question is from last year, but I have found a solution that others searching will find useful:

dsmod user CAN edit all AD attributes, it's just that MSDN does not list all of the attribute names to modify. Some examples:

City = l
Postalcode = zip
State = st
Street = streetaddress

kouti has a nice list of all AD Attributes: http://www.kouti.com/tables/userattributes.htm

Hope this helps!



回答2:

The command Get-Person in PowerShell Pipeworks will do active directory lookups. This will contain the ADSI path to the real object. You can use this to set data.

 $realPerson  =[adsi]((Get-Person -Alias $env:USERNAME).adspath)
 $realPerson.Telephone = "206-555-1212"
 $realPerson.SetInfo()


回答3:

Set-ADUser does everything I was looking for and it's more or less built in.

It is an Active Directory Domain Services Cmdlet that must be enabled first in windows/powershell. See install/config instructions here: http://blogs.technet.com/b/heyscriptingguy/archive/2010/01/25/hey-scripting-guy-january-25-2010.aspx

See usage instructions here: http://blogs.technet.com/b/heyscriptingguy/archive/2012/10/31/use-powershell-to-modify-existing-user-accounts-in-active-directory.aspx

Here are some of the fields it's capable of pushing (among many other settings):

[-City <String>] 
[-Company <String>] 
[-Country <String>]
[-Department <String>] 
[-Description <String>] 
[-DisplayName <String>] 
[-Division <String>]
[-EmailAddress <String>]
[-EmployeeID <String>] 
[-EmployeeNumber <String>] 
[-Fax <String>] 
[-GivenName <String>] 
[-HomeDirectory <String>] 
[-HomeDrive <String>] 
[-HomePage <String>] 
[-HomePhone <String>]
[-Initials <String>] 
[-Manager <ADUser>]
[-MobilePhone <String>] 
[-Office <String>]
[-OfficePhone <String>] 
[-Organization <String>] 
[-OtherName <String>] 
[-POBox <String>]
[-PostalCode <String>]
[-ProfilePath <String>] 
[-ScriptPath <String>]
[-Server <String>]
[-State <String>] 
[-StreetAddress <String>] 
[-Surname <String>] 
[-Title <String>]

It can even be used like an object with instance parameters like the previous reply was suggesting:

C:\PS>$user = Get-ADUser GlenJohn -Properties mail,department
$user.mail = "glen@fabrikam.com"
$user.department = "Accounting"
Set-ADUser -instance $user

Should make it easy to build scripts around. Very cool!



回答4:

@OllieSmith, your statement is wrong - neither DSADD nor DSMOD are capable to change Street, City or any of those above mentioned attributes, at least not in an Server 2008 R2 / Server 2012 enviroment. (maybe it was correct for Server 2003)

C:\>dsmod user "CN=mde.bs.7001,OU=MDE,OU=Users,OU=Basel,OU=RCL,OU=RAG_Users_Computers,DC=ra,DC=wan" -StreetAddress "Teststreet"
dsmod failed:'-StreetAddress' is an unknown parameter.

type dsmod /? for help.

C:\>dsmod user "CN=mde.bs.7001,OU=MDE,OU=Users,OU=Basel,OU=RCL,OU=RAG_Users_Computers,DC=ra,DC=wan" -desc "Description"
dsmod succeeded:CN=mde.bs.7001,OU=MDE,OU=Users,OU=Basel,OU=RCL,OU=RAG_Users_Computers,DC=ra,DC=wan

The only attributes changeable ARE those one listed by "DSADD /?" or "DSMOD /?". To change those above mentioned attributes you have to use either Powershell, WSH or 3rd Party Tools (like f.e. the free Wisesoft Bulk AD Users Tool --> http://www.wisesoft.co.uk/software/bulkadusers/default.aspx).