Re: Create computer account in specified AD OUs



I've found some resources with the following script, however:


'Script configuration
strBase=
"OU=HK,OU=Workstations,OU=HKG,DC=momo,DC=hk,DC=pwcinternal,DC=com"
strComp = "WORKSTATION001"
strDescr = "Test PC"


'ADS_User_Flag_Enum
Const ADS_UF_WORKSTATION_TRUST_ACOUNT = &h1000


Set objCont = GetObject("LDAP://"; & strBase)
Set objComp =
objCont.Create("computer","OU=HK,OU=Workstations,OU=HKG,DC=momo,DC=hk,DC=pw­cinternal,DC=com"

& StrComp)
objComp.Put "sAMAccountName", StrComp & "$"
objComp.Put "description", strDesc
objCom.Setinfo
WScript.Echo "Computer account for " & StrComp & " created."


But when it actually runs it gives me an error regarding the strComp
value.... any one have ideas on how to fix this..........


I will be running the script from a DC with Domain Admin rights......

.



Relevant Pages

  • Re: Delete Computer Resource via WMI
    ... > Set objComp = GetObject _ ... > As the computer name does exist in the systems collection, ... SMS_R_System the only key property is ResourceID. ... 'begin script section ...
    (microsoft.public.sms.inventory)
  • Re: Delete Computer Resource via WMI
    ... the SMS_R_System threw an error when used in the MS example script: ... Set objComp = GetObject _ ... As the computer name does exist in the systems collection, ...
    (microsoft.public.sms.inventory)