ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Anyone have a powershell line to create a new admin account

    IT Discussion
    windows 7 administrators powershell
    7
    18
    1.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ObsolesceO
      Obsolesce
      last edited by

      Or if you use SaltStack:

      https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.win_useradd.html

      black3dynamiteB 1 Reply Last reply Reply Quote 1
      • black3dynamiteB
        black3dynamite @Obsolesce
        last edited by

        @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.

        ObsolesceO 1 Reply Last reply Reply Quote 0
        • ObsolesceO
          Obsolesce @black3dynamite
          last edited by

          @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

          1 Reply Last reply Reply Quote 1
          • thwrT
            thwr @JaredBusch
            last edited by

            @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

            JaredBuschJ 1 Reply Last reply Reply Quote 1
            • JaredBuschJ
              JaredBusch @thwr
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch @black3dynamite
                last edited by

                @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.1

                Add-LocalGroupMember
                https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/add-localgroupmember?view=powershell-5.1

                Windows Management Framework 5.1 needs to be installed on Windows 7.
                https://www.microsoft.com/en-us/download/details.aspx?id=54616

                You can find out the current version on Windows 7 with this command in PowerShell.
                $PSVersionTable.PSVersion

                well fuck..
                0_1517335976163_5d24ba6b-28fc-45fe-b08c-21f50b7e2e6d-image.png

                ObsolesceO 2 Replies Last reply Reply Quote 1
                • ObsolesceO
                  Obsolesce @JaredBusch
                  last edited by

                  @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.1

                  Add-LocalGroupMember
                  https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/add-localgroupmember?view=powershell-5.1

                  Windows Management Framework 5.1 needs to be installed on Windows 7.
                  https://www.microsoft.com/en-us/download/details.aspx?id=54616

                  You can find out the current version on Windows 7 with this command in PowerShell.
                  $PSVersionTable.PSVersion

                  well fuck..
                  0_1517335976163_5d24ba6b-28fc-45fe-b08c-21f50b7e2e6d-image.png

                  Lol

                  1 Reply Last reply Reply Quote 0
                  • ObsolesceO
                    Obsolesce @JaredBusch
                    last edited by

                    @jaredbusch Looks like SaltStack is the way to go. PSTools makes it easy too if you need a quick n easy.

                    JaredBuschJ 1 Reply Last reply Reply Quote 1
                    • JaredBuschJ
                      JaredBusch @Obsolesce
                      last edited by

                      @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.

                      DashrenderD 1 Reply Last reply Reply Quote 2
                      • DashrenderD
                        Dashrender @JaredBusch
                        last edited by

                        @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.

                        1 Reply Last reply Reply Quote 0
                        • matteo nunziatiM
                          matteo nunziati @JaredBusch
                          last edited by

                          @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()
                          
                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post