#188473 - 2008-06-2907:10 PMConvert AD create user to Standalone create user
GargoyleGargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I know that this should be easy, but I can't seem to find (I am sure it is here somewhere) the required provider and methods to create users on a standalone server.
I have a list of 300 users that I must add to 15 servers that are all standalone (not a part of any domain).
Here is my domain create user script, how do I change it to work as a standalone?
Code:
SRnd(@MSECS)
SetOption("CaseSensitivity","ON")
Dim $Accounts[2,0]
$Count = 0
Open(1,"Users.txt")
$Line = ReadLine(1)
While @ERROR = 0
ReDim Preserve $Accounts[2,$Count]
$Accounts[0,$Count] = Split($Line,",")[0] ; Full Name
$Accounts[1,$Count] = Split($Line,",")[1] ; SAMAccountName
$Accounts[2,$Count] = MakePass() ;Generated Password
$Count = $Count +1
$Line = ReadLine(1)
Loop
Close (1)
Open (1,"users_Wpass.txt",5)
For $Element = 0 to ($Count -1)
WriteLine(1,$Accounts[0,$Element]+" "+$Accounts[1,$Element]+" "+$Accounts[2,$Element]+@CRLF)
$Domain = GetObject("LDAP://cn=Users,dc=us,dc=fabricom,dc=com")
$user = $Domain.Create("user", "cn=" + $Accounts[0,$Element])
$User.Put ("sAMAccountName", $Accounts[1,$Element])
$user.SetPassword ($Account[2,$Element])
$user.Description = "Voice Admin"
$user.SetInfo
$GroupObj = GetObject("LDAP://cn=Administrators,cn=Builtin,dc=us,dc=fabricom,dc=com")
$UserObj = GetObject("LDAP://cn="+$Accounts[0,$Element]+",cn=Users,dc=us,dc=fabricom,dc=com")
$GroupObj.add ($UserObj.ADsPath)
$GroupObj.SetInfo
$GroupObj = GetObject("LDAP://cn=Domain Admins,cn=Users,dc=us,dc=fabricom,dc=com")
$GroupObj.add ($UserObj.ADsPath)
$GroupObj.SetInfo
$userObj.pwdLastSet = -1
$userObj.AccountDisabled = 0
$userObj.SetPassword ($Account[2,$Element)
$userObj.setinfo
Next
Close(1)
Function MakePass()
$MakePass = ""
While Len($MakePass) < 8
$Value = Rnd(122)
If $Value >= 48 And $Value <= 57
$MakePass = $MakePass + Chr($Value)
EndIf
If $Value >= 65 And $Value <= 90
$MakePass = $MakePass + Chr($Value)
EndIf
If $Value >= 97 And $Value <= 122
$MakePass = $MakePass + Chr($Value)
EndIf
Loop
EndFunction
_________________________
Today is the tomorrow you worried about yesterday.
#188478 - 2008-06-3001:58 PMRe: Convert AD create user to Standalone create user
[Re: Gargoyle]
Glenn BarnasGlenn Barnas KiX Supporter
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Given the few times I've needed to create local accounts or groups across a set of computers, I've used PSExec with the Net command. I might still have that code if you're interested in a quick solution.
Glenn
_________________________ Actually I am a Rocket Scientist!
#188483 - 2008-06-3004:23 PMRe: Convert AD create user to Standalone create user
[Re: Glenn Barnas]
GargoyleGargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Any hints or tidbits would be appreciated. Been too long since I have had to work with Standalone machines. Have to love working in a Cisco IPCC enviroment.
_________________________
Today is the tomorrow you worried about yesterday.
#188484 - 2008-06-3005:35 PMRe: Convert AD create user to Standalone create user
[Re: Gargoyle]
Glenn BarnasGlenn Barnas KiX Supporter
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Here's what I used to push out groups - uses would be similar. You need a copy of PSExec.exe for this, or modifiy it to use some WMI-based remote exec process.
Here's the sample GrpMgmt.ini file
[COMMON]
# LocalGroups = comma-separated list of groups to update
LocalGroups=Administrators
# for each group defined in LocalGroups, a corresponding section is needed
[Administrators]
# MakeLocal=Y/N - should the local group be created?
MakeLocal=N
# AddAccounts= comma-separated list of accounts to add to the defined local group
AddAccounts=DOMAIN\Security_Group
# DelAccounts= comma-separated list of accounts to remove from the defined local group
DelAccounts=
# [NewGroup] Name of local group
# MakeLocal=Y Create it? (Y/N)
# AddAccounts=Accounts,to,add
# DelAccounts=Accounts,to,delete
The "servers.txt" file is just a plain list of computers to process, one host per line.
As you can see, this is pretty old code, but it works.
Glenn
_________________________ Actually I am a Rocket Scientist!