Anyone have a powershell line to create a new admin account
-
@black3dynamite said in Anyone have a powershell line to create a new admin account:
Within a powershell script
cmd.exe /c "net user adminuser password /add" cmd.exe /c "net localgroup administrators adminuser /add" cmd.exe /c "wmic path Win32_UserAccount where Name='adminuser' set PasswordExpires=false" #To remove Users group from adminuser and only have Administrators cmd.exe /c "net localgroup users adminuser /del"
I have that, but I swear I did it with powershell once but cannot find what I did.
/me rants about needing better notes.
-
New-LocalUser -Name "SpongeBob" -Description "Badass Admin" Add-LocalGroupMember -Group "Administrators" -Member "SpongeBob"
New-LocalUser
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/new-localuser?view=powershell-5.1Add-LocalGroupMember
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/add-localgroupmember?view=powershell-5.1 -
@tim_g said in Anyone have a powershell line to create a new admin account:
New-LocalUser -Name "SpongeBob" -Description "Badass Admin" Add-LocalGroupMember -Group "Administrators" -Member "SpongeBob"
New-LocalUser
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/new-localuser?view=powershell-5.1Add-LocalGroupMember
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/add-localgroupmember?view=powershell-5.1Windows Management Framework 5.1 needs to be installed on Windows 7.
https://www.microsoft.com/en-us/download/details.aspx?id=54616You can find out the current version on Windows 7 with this command in PowerShell.
$PSVersionTable.PSVersion
-
Or if you use SaltStack:
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.win_useradd.html
-
@tim_g said in Anyone have a powershell line to create a new admin account:
Or if you use SaltStack:
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.win_useradd.html
Those commands looks so much easier to use.
-
@black3dynamite said in Anyone have a powershell line to create a new admin account:
@tim_g said in Anyone have a powershell line to create a new admin account:
Or if you use SaltStack:
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.win_useradd.html
Those commands looks so much easier to use.
SaltStack makes management extremely easier
-
@jaredbusch said in Anyone have a powershell line to create a new admin account:
I have a handful of Windows 7 machiens not on a domain.
I want to put a new Admin account on them.
The current user accounts have admin rights, which I will remove, I have ScreenConnect installed and running with admin perms. So I can pop a powershell via the ScreenConnect command window easily to do this.
AD? New-ADuser or so. On the road ATM, can check later
-
@thwr said in Anyone have a powershell line to create a new admin account:
@jaredbusch said in Anyone have a powershell line to create a new admin account:
I have a handful of Windows 7 machiens not on a domain.
I want to put a new Admin account on them.
The current user accounts have admin rights, which I will remove, I have ScreenConnect installed and running with admin perms. So I can pop a powershell via the ScreenConnect command window easily to do this.
AD? New-ADuser or so. On the road ATM, can check later
Local user.
-
@black3dynamite said in Anyone have a powershell line to create a new admin account:
@tim_g said in Anyone have a powershell line to create a new admin account:
New-LocalUser -Name "SpongeBob" -Description "Badass Admin" Add-LocalGroupMember -Group "Administrators" -Member "SpongeBob"
New-LocalUser
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/new-localuser?view=powershell-5.1Add-LocalGroupMember
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/add-localgroupmember?view=powershell-5.1Windows Management Framework 5.1 needs to be installed on Windows 7.
https://www.microsoft.com/en-us/download/details.aspx?id=54616You can find out the current version on Windows 7 with this command in PowerShell.
$PSVersionTable.PSVersion
well fuck..
-
@jaredbusch said in Anyone have a powershell line to create a new admin account:
@black3dynamite said in Anyone have a powershell line to create a new admin account:
@tim_g said in Anyone have a powershell line to create a new admin account:
New-LocalUser -Name "SpongeBob" -Description "Badass Admin" Add-LocalGroupMember -Group "Administrators" -Member "SpongeBob"
New-LocalUser
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/new-localuser?view=powershell-5.1Add-LocalGroupMember
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/add-localgroupmember?view=powershell-5.1Windows Management Framework 5.1 needs to be installed on Windows 7.
https://www.microsoft.com/en-us/download/details.aspx?id=54616You can find out the current version on Windows 7 with this command in PowerShell.
$PSVersionTable.PSVersion
well fuck..
Lol
-
@jaredbusch Looks like SaltStack is the way to go. PSTools makes it easy too if you need a quick n easy.
-
@tim_g said in Anyone have a powershell line to create a new admin account:
@jaredbusch Looks like SaltStack is the way to go. PSTools makes it easy too if you need a quick n easy.
old cmd line will work. jsut not what I wanted to do.
-
@jaredbusch said in Anyone have a powershell line to create a new admin account:
@tim_g said in Anyone have a powershell line to create a new admin account:
@jaredbusch Looks like SaltStack is the way to go. PSTools makes it easy too if you need a quick n easy.
old cmd line will work. jsut not what I wanted to do.
run each command from SC.. not as fast as one click.. but still not bad.
-
@jaredbusch said in Anyone have a powershell line to create a new admin account:
I have a handful of Windows 7 machiens not on a domain.
I want to put a new Admin account on them.
The current user accounts have admin rights, which I will remove, I have ScreenConnect installed and running with admin perms. So I can pop a powershell via the ScreenConnect command window easily to do this.
not tested... maybe this thread can help with PS 2.0. Quoting code here:
# Create new local Admin user for script purposes $Computer = [ADSI]"WinNT://$Env:COMPUTERNAME,Computer" $LocalAdmin = $Computer.Create("User", "LocalAdmin") $LocalAdmin.SetPassword("Password01") $LocalAdmin.SetInfo() $LocalAdmin.FullName = "Local Admin by Powershell" $LocalAdmin.SetInfo() $LocalAdmin.UserFlags = 64 + 65536 # ADS_UF_PASSWD_CANT_CHANGE + ADS_UF_DONT_EXPIRE_PASSWD $LocalAdmin.SetInfo()