Create a local user and login to it with administrator privileges from powershell RRS feed

  • General discussion

  • I am trying to figure out how to login into to local user right after I create it from powershell. I need to log into to local user so I can make changes to the registry. So this is what I have so far...

    New-LocalUser -Name "User01" - FullName "New User" -Description "New User" -NoPassword
    NET LOCALGROUP "Users" "New User" /add
    Set-LocalUser -Name "New User" -PasswordNeverExpires:$true

    After I have created the new user with no password, added to the local group and set the password never expire flag. I want to login into User01 in the same session and make changes to its registry. Is that at all possible?

    I know you can manually switch user and log in to local user. This creates an entry in HKLM with SID which can be used to make changes but I don't want to manually switch. I want to switch user in powershell and log in so the entry is created. Is that possible? Or Is there any other way to do this?

    • Changed type Bill_Stewart Friday, January 26, 2018 3:04 PM
    • Moved by Bill_Stewart Friday, January 26, 2018 3:04 PM This is not "teach me system administration basics" forum
    Friday, December 1, 2017 9:55 PM

All replies

  • Use a GPO user preference if you need to update the registry for individual users.

    -- Bill Stewart [Bill_Stewart]

    Friday, December 1, 2017 10:18 PM
  • You cannot remotely connect to a user account that ahs no password.

    What you are asking cannot be done via a script.

    It sounds like you are asking how to make changes to a users profile without the user ever having logged in.  It would be better to describe what you need to change.  Most things can be done via Group Policy which is the recommended method for configuring and provisioning most user properties and resources.


    • Edited by jrv Friday, December 1, 2017 11:04 PM
    Friday, December 1, 2017 11:02 PM
  • Sorry if I wasn't clear in my original post. I want to make changes to the new user's registry from admin account. Once again, this needs to be done right after I create the user via powershell or script. I need to add registry value in that user to make it kiosk mode. below is what I am trying to do.


    Monday, December 4, 2017 5:18 PM
  • Once again, this needs to be done right after I create the user via powershell or script.

    Why? Just configure a GPO to add the registry data you need.

    -- Bill Stewart [Bill_Stewart]

    Monday, December 4, 2017 5:36 PM
  • Can you access local user's registry within Administrator's GPO?
    Monday, December 4, 2017 5:45 PM
  • For details about how to use GPOs, start with the Microsoft documentation; if you still have questions, you can ask in the Group Policy forum.

    -- Bill Stewart [Bill_Stewart]

    Monday, December 4, 2017 5:53 PM