
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2015
01:31 PM
- last edited on
‎07-04-2023
05:29 PM
by
ErikT
Creates a new local user and adds it to the local admin group
Rem: You need to add the user and password as a parameters.
Rem: If you do not add a username parameter, the username is default set to: Lansweeperadm
Rem: If you do not add a password parameter, the password is default set to: Strongpassword0*
Rem: Copy the code below and save it as Create_Admin_User.vbs at the {PackageShare}\Scripts folder
Set Arg = WScript.Arguments
if Arg.count = 2 then
strUser = Arg(0) 'Pass the username as parameter to the script
strPassword = Arg(1) 'Pass the password as parameter to the script
end if
if IsEmpty(strUser) or IsNull(strUser) or strUser = "" or IsEmpty(strPassword) or IsNull(strPassword) or strPassword = "" then
strUser = "Lansweeperadm"
strPassword = "Strongpassword0*"
end if
Set objWshNet = CreateObject("WScript.Network")
strComputer = objWshNet.ComputerName
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("SELECT Name,SID from Win32_Group where domain ='" & strcomputer & "'")
For Each objItem in colItems
sidAdmin = objItem.SID
if sidadmin = "S-1-5-32-544" then
strGroup = objItem.Name
end if
Next
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", strUser)
objUser.SetPassword strpassword
objUser.SetInfo
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ",group")
objGroup.Add(objUser.ADsPath)
- Labels:
-
Share(d) Packages

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 12:37 PM
I have followed this but when i try do it i get a access denied message
Line: 28
Char: 1
Error: Access denied
Code: 8007005
Source: Active directory
I have run as system
I have run as scanning cred(Domain Admin)
But its both the same
HELP!!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2016 02:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2015 04:54 PM
If you don't want him to be admin you should remove the part where the user is added to the admin group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 09:33 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 02:54 PM
The code there (re)sets the password for the administrator


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2015 06:52 PM
I am NOT a VB Script person....... learning curves are so much fun.......

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2015 05:23 PM
Good catch


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2015 04:18 PM
Set colItems = objWMIService.ExecQuery ("SELECT Name,SID from Win32_Group
where domain ='" & strcomputer & "'")
once I changed it to a single line:
Set colItems = objWMIService.ExecQuery ("SELECT Name,SID from Win32_Group where domain ='" & strcomputer & "'")
Everything ran like a champ.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2015 08:42 AM
