Create a one or more local admin user using sccm 2111

PerserPolis-1732 1,556 Reputation points
2022-02-04T13:35:38.307+00:00

Hi,

I want to create and deploy on all my machines a local Admin Account.
I have created a TS with Command line and use the following

powershell.exe New-LocalUser -AccountNeverExpires:$true -Password ( ConvertTo-SecureString -AsPlainText -Force 'lUAq') -Name 'localAdmin' -FullName "Local Administrator" -Description "Local Administrator" | Add-LocalGroupMember -Group administrators

If I run it , I get always the error code

Error executing Task Sequence Manager service. Code 0x80004005
Task sequence execution failed with error code 80004005

But If I run the same command line as "Script" with sccm script, it is working. Any Idea?

My second question is the following.

I want to create on all my machines a local admin user with different name on different machine. for example

the machine name is called "test" and the local admin user should be called "testAdmin" and the other machine is called "test2" the local admin user should be called "test2Admin"

Is there anyway to do that in on step?

Regards

Microsoft Configuration Manager Application
Microsoft Configuration Manager Application
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Application: A computer program designed to carry out a specific task other than one relating to the operation of the computer itself, typically to be used by end users.
471 questions
0 comments No comments
{count} votes

Accepted answer
  1. AllenLiu-MSFT 42,826 Reputation points Microsoft Vendor
    2022-02-11T03:38:50.287+00:00

    Hi, @PerserPolis-1732

    Do you mean: if the user name is User1, then the FullName will be "User1 administrator".

    $a=$env:username+"Admin"
    $b=$env:username+" Administrator"
    New-LocalUser -AccountNeverExpires:$true -Password ( ConvertTo-SecureString -AsPlainText -Force 'password') -Name $a -FullName $b -Description "Local Administrator" | Add-LocalGroupMember -Group administrators.


7 additional answers

Sort by: Most helpful
  1. AllenLiu-MSFT 42,826 Reputation points Microsoft Vendor
    2022-02-09T07:34:41.737+00:00

    Hi, @PerserPolis-1732

    By default SCCM task sequence are executed with the SYSTEM account of the current computer.
    How about run this script with "Scripts" function in SCCM?

    0 comments No comments

  2. PerserPolis-1732 1,556 Reputation points
    2022-02-09T09:41:38.957+00:00

    I will check it and let you know.

    Is there anyway to have a equivalent FullName like "username+"Admin"" as created and NOT "Local Administrator"

    $a=$env:username+"Admin"
    New-LocalUser -AccountNeverExpires:$true -Password ( ConvertTo-SecureString -AsPlainText -Force 'password') -Name $a -FullName "Local Administrator" -Description "Local Administrator" | Add-LocalGroupMember -Group administrators.

    Regards

    0 comments No comments

  3. Anonymous
    2022-11-25T06:22:12.32+00:00

    Hi Team,

    I want to create and deploy on all my domain machines a local Account with Default password.
    Expect solutions.

    0 comments No comments