How to auto rename domain computers based on Company naming Convention


my company uses following naming convention domain computers

companyname1xx   corporate office

companyname2xx - dallas office

companyname3xx - houston office

companyname4xx - austin office

each office has own ou in active directory computer accounts. don't know active directory , took on role of interim server administrator. there way can run script , assign computers in each ou unique computer name based on naming convention location. if scripting isn't way go open suggestions. thanks. -jr


hey there,

powershell friend. tested code below. firstly queries computer in dallas ou , rename them pattern of "dallas1","dallas2" , on. @ end restart system make changes committed. have look:

#get computers in dallas ou $dallaspc=get-adcomputer -filter * -searchbase "ou=dallas,dc=contoso,dc=com" $i = 1 #starting process each 1 foreach($pc in $dallaspc) {  #changing computer name get-wmiobject win32_computersystem -computername $pc.name -authentication 6 | foreach-object {$_.rename("dallas" + $i ,"password","administrator")}  #reboot complete process get-wmiobject win32_operatingsystem -computername $pc.name | foreach-object {$_.win32shutdown(6)} $i = $i + 1 }

do not forget change dn , insert domain admin user , password in place.

hope helps.


mahdi tehrani   |     |   www.mahditehrani.ir
please click on propose answer or to mark post and helpful other people.
posting provided as-is no warranties, , confers no rights.





Windows Server  >  Directory Services



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com