Comments (13)

  1. Anonymous says:

    When I try to run the above word for word except the $objUser.description = "Test user" line, I CHANGE THAT TO $objUser.InvokeSet(‘description’,’Test User’) I get the following error:
    Exception calling "SetInfo" with "0" argument(s): "Access is denied.
    "
    At C:Users####DocumentsRobpowershellCreateLocalUser.ps1:90 char:17
    + $objUser.SetInfo <<<< ()
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvokeTI

    Exception calling "SetInfo" with "0" argument(s): "Access is denied.
    "
    At C:Users####DocumentsRobpowershellCreateLocalUser.ps1:94 char:17
    + $objUser.SetInfo <<<< ()
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvokeTI

    I am new to PowerShell so not sure what is wrong but we also have Access Denied issues with Batch files too. I am using a domain account that has local administrator rights.

  2. Anonymous says:

    Hi Scripting guys,

    I am quite a rookie to scripting and this seems to be an easy script to follow and study, However i am still not sure what i have to modify to suit my project. Eg i want 7 PCs in 1 OU to have the same local username called "Trainer" password to be "123456" and in a local group called "Trainers".

    If i copy and save his script which part should i edit or modify to suit my project?

    I plan to execute the script via a GPO.

  3. Anonymous says:

    HI,

    I'am new in Powershell and i want to create a user with powershell, but i'am getting the next error  "The following exception occurred while retrieving member "create": "Unknown error (0x80005000)" what do i wrong?

    $objou=[ADSI]"LDAP://ou=users,dc=test,dc=lokaal"

    $objuser=$objou.create("user",CN=Charles Crude")

    Thanks

    Dirk

  4. jrv says:

    @Dirk

    Set-AdUser -Identity <userid>  -ChangePasswordAtLogon $false -CannotChangePassword $false

    The blog Is very dated.  We can use CmdLets on WS2003 and later domains (WS2003 with one Windows 7)

  5. ali says:

    Hi,

    how I can set the Full Name for the user ID and also make it member of Local Administrators?

    Thanks,

    Regards.

  6. Andrew Brehm says:

    This totally doesn't work for me.

    When I create the directory entry object like here (my computer's name is "pauly"):

    $computer = [ADSI]"WinNT://pauly"

    I get an object $computer that gives an error when I try to look at it:

    format-default : The following exception occurred while retrieving member "PSComputerName": "Unknown error (0x80005000)

    Plus it doesn't have a "create" method:

    $user = $computer.Create("User", "username")

    The following exception occurred while retrieving member "create": "Unknown error (0x80005000)"

    What am I doing wrong?

  7. L says:

    How do you check or uncheck "user must change password at next logon" and "user cannot change password"?

  8. L says:

    i'm using powershell 2.0 with windows 7/windserver 2008 .. no active directory -no domain

    this doesn't work::@Dirk

    Set-AdUser -Identity <userid>  -ChangePasswordAtLogon $false -CannotChangePassword $false

    The blog Is very dated.  We can use CmdLets on WS2003 and later domains (WS2003 with one Windows 7)

    any other ideas?

  9. Dev says:

    L,

    you aren't in a domain, you can't use the ADUser cmdlet. Lookup another guide for creating local users through ADSI in a workgroup.

  10. powershelljunkie says:

    When I attempt to run the line that state $objUser.Description, I get the following exception:

    Cannot set the Value property for PSMemberInfo object of type "System.Management.Automation.PSMethod".
    At C:ScriptsCreateLocalUser.ps1:109 char:10
    + $objUser. <<<< description =$description
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

  11. powershelljunkie says:

    This is the corrected code for setting description using ADSI:

    $objUser.InvokeSet(‘description’,’Test User’)

  12. Jeff25 says:

    thanks for the script.
    any ideas how to tick the checkbox "user must change password at next logon" and add it to local administrator ?

  13. Rookie1082 says:

    Sorry for digging up an old thread. I need to be able to create a local user that is based on the units serial number. Either poweshell or net user would do. Hell at this point even a vbs.

    I have a vbs that pulls a units serial number and then pipes it out to a temporary cmd that then is called and assigns the SN with the SET SN variable. I then tried “net user %SN% password /add” without the quotes. The user shows up as literally %SN and not the variable. Any ideas?

Skip to main content