none
SetPassword failure on Windows Server 2012 RRS feed

  • Question

  • I got redirected to this forum from the 'windows server 2012' forum. 

    I am trying to figure out why the following script fails on Windows Server 2012 RC.

      $Group = [ADSI]"WinNT://localhost/Administrator,user"
      $Group.Invoke("SetPassword","WnSrv12**2")

    The error that I get is:

      Exception calling "Invoke" with "2" argument(s): "The specified network password is not  correct.

    The same script works on Windows Server 2008 R2.

    Can someone help?

    Thanks.

    Friday, June 15, 2012 7:27 PM

Answers

  • Somehow I think that was the major point of my post.  Only Bartek seems to be able oto understand.  The one thing I changed was

    'localhost'.  In Win7 fuynamic support for localhost has been dropped for security reasons.  Localhost can no longer be specified in LMHOSTS.  The router and local address 127.0.0.1 are built into the internal router since Vista I believe.

    You can still use 'localhost' at the commandline but not from many other areas.

    From the 'hosts' file on Windows7:

    # localhost name resolution is handled within DNS itself.
    #       127.0.0.1       localhost
    #       ::1             localhost


    ¯\_(ツ)_/¯

    Tuesday, June 26, 2012 8:27 PM

All replies

  • I'm getting the same error.  Same situation where it is working on Windows Server 2008 R2.  Anyone have any ideas?

    Thanks,

    Mike


    blog - http://www.codesmartnothard.com

    Wednesday, June 20, 2012 1:40 AM
  • Does the following work:

    $Group.SetPassword("WnSrv12**2")

    -----

    Of course $Group refers to a local user object, not a group object. And, you must use elevated privileges to reset passwords (Run as administrator).


    Richard Mueller - MVP Directory Services

    Wednesday, June 20, 2012 2:55 PM
    Moderator
  • Richard,

    In my example, I am using the SetPassword like you described and I am running PS with elevated permissions but getting the same error.  I have also posted my example on StackOverflow.

    http://stackoverflow.com/questions/11112293/windows-server-2012-rc-powershell-error-exception-calling-setinfo-with-0-ar

    Thanks,

    Mike


    blog - http://www.codesmartnothard.com

    Wednesday, June 20, 2012 6:01 PM
  • Try it this way as you may not be getting th eobject and not seeing that:

    This is the correct method:

    $user=[ADSI]"WinNT://$env:computername/Administrator"
    if($user){
         $user.SetPassword("Suss17Me38Out")
    }else{
        Write-Host "no such user" -fore red
    }

    Not finding the user does not throw an error it just doesn not create an object.


    ¯\_(ツ)_/¯

    Wednesday, June 20, 2012 6:23 PM
  • Jrv,

    What about creating a user?  This is what I'm trying to do in my example and I am getting the same error.

    $ComputerName = 'localhost'
    $computer = [ADSI]"WinNT://$ComputerName"
    $user = $computer.Create("User","Test")
    $user.setpassword("P2ssw0rd")
    $user.put("fullname","Test User")
    $user.SetInfo()
    $User.UserFlags[0] = $User.UserFlags[0] -bor 0x10000  #ADS_UF_DONT_EXPIRE_PASSWD flag is 0x10000
    $User.SetInfo()

    Thanks,

    Mike


    blog - http://www.codesmartnothard.com

    Thursday, June 21, 2012 2:40 AM
  • The question was "SetPassword" failure.


    ¯\_(ツ)_/¯

    Thursday, June 21, 2012 6:50 AM
  • Your issue is 'localhost' - once you use *actual* computername (as jrv did) it all "clicks". So replace $ComputerName with $env:ComputerName and you should be good to go.

    I tried same code jrv provided with localhost and got same error message you had, than tried your code with $env:computername - and now I have test user on my system.

    Tuesday, June 26, 2012 10:38 AM
    Moderator
  • Bartek,

    This worked for me.  Thanks!

    Mike


    blog - http://www.codesmartnothard.com

    Tuesday, June 26, 2012 8:03 PM
  • Somehow I think that was the major point of my post.  Only Bartek seems to be able oto understand.  The one thing I changed was

    'localhost'.  In Win7 fuynamic support for localhost has been dropped for security reasons.  Localhost can no longer be specified in LMHOSTS.  The router and local address 127.0.0.1 are built into the internal router since Vista I believe.

    You can still use 'localhost' at the commandline but not from many other areas.

    From the 'hosts' file on Windows7:

    # localhost name resolution is handled within DNS itself.
    #       127.0.0.1       localhost
    #       ::1             localhost


    ¯\_(ツ)_/¯

    Tuesday, June 26, 2012 8:27 PM