Re: changes password.

From: A.P.J. Louwerse (apj.louwerse_at_sgtongerlo.nl)
Date: 07/15/04


Date: Thu, 15 Jul 2004 08:51:38 +0200

What is the difference between setting a password and changing a password ?

Arthur.

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> schreef in bericht
news:O2xgGyUaEHA.996@TK2MSFTNGP12.phx.gbl...
> anonymous@discussions.microsoft.com wrote:
>
> > How to changes administrator local password (in every
> > client that connected to one domain)at a time?
> Hi
>
> As long as the computers are joined to an Active Directory domain:
>
> You could do it in a computer startup script (with a GPO) that runs
> as part of the boot up process (before the user logs in). It runs
> under the system context and has admin rights.
>
> To avoid users being able to read the script where the password is
> stored, grant read access only for the AD group "Domain Computers"
> to the script file.
>
>
> As long as the Administrator account name is "Administrator", this
> vbscript will set the password on the account:
>
> '--------------------8<----------------------
> sNewPassword = "testpassword"
> Set oWshNet = CreateObject("WScript.Network")
> sComputer = oWshNet.ComputerName
>
> On Error Resume Next
> Set oUser = GetObject("WinNT://" & sComputer & "/Administrator,user")
> oUser.SetPassword sNewPassword
> oUser.SetInfo
> On Error Goto 0
> '--------------------8<----------------------
>
>
> If you want to change the password instead of setting it (but this
> means you will need to be sure that you know the old password on
> all the computers), use oUser.ChangePassword instead of
> oUser.SetPassword, like this:
>
> oUser.ChangePassword "old pwd here", sNewPassword
>
>
>
> If there is a chance that the name of the administrator is not
> "Administrator" (e.g. the account is renamed, or you have some
> non-English OS versions), you could use this version instead:
>
> '--------------------8<----------------------
> sNewPassword = "testpassword"
> Set oWshNet = CreateObject("WScript.Network")
> sComputer = oWshNet.ComputerName
> sAdminName = GetAdministratorName
>
> On Error Resume Next
> Set oUser = GetObject("WinNT://" & sComputer & "/" & sAdminName & ",user")
> oUser.SetPassword sNewPassword
> oUser.SetInfo
> On Error Goto 0
>
>
> Function GetAdministratorName()
>
> Dim sUserSID, oWshNetwork, oUserAccount
>
> Set oWshNetwork = CreateObject("WScript.Network")
> Set oUserAccounts = GetObject( _
> "winmgmts://" & oWshNetwork.UserDomain & "/root/cimv2") _
> .ExecQuery("Select Name, SID from Win32_UserAccount" _
> & " WHERE Domain = '" & oWshNetwork.ComputerName & "'")
>
> On Error Resume Next
> For Each oUserAccount In oUserAccounts
> If Left(oUserAccount.SID, 9) = "S-1-5-21-" And _
> Right(oUserAccount.SID, 4) = "-500" Then
> GetAdministratorName = oUserAccount.Name
> Exit For
> End if
> Next
> End Function
> '--------------------8<----------------------
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/community/scriptcenter/default.mspx



Relevant Pages

  • Re: Finding users in local admin groups
    ... > Here is a vbscript that you can run against a remote computer that moves ... > *local* users except 'Administrator) from the Administrators group to the ... You should also add to the script logging to a file of the ... > you moved on what computers. ...
    (microsoft.public.win2000.security)
  • Re: change local admin password
    ... If the computers are in an Active Directory domain: ... You could do it in a computer startup script that runs ... grant read access only for the AD group "Domain Computers" ... Dim sUserSID, oWshNetwork, oUserAccount ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Change local administrator password ? through GPO or push script ?
    ... I would like to change the local administrator password of every computers member of my AD domain but I am not sure of the best method. ... Create a vbs script that points to the local computer and then deploy this script by GPO. ... This attribute will permit to know wich admin password is configured for this machine. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Not so Newbie
    ... The script is designed for situations like yours. ... wit 35+ computers and to go to each of those computers to individualy ... Prompt for an executable to run on each remote computer in the group. ... so you know where the deployment failed. ...
    (microsoft.public.windows.server.scripting)
  • Re: Sending computer name to txt file if file didnt copy?
    ... look intot he MSI etc suggestion. ... 150 computers and dont have access to AD to do it that way. ... Const OverwriteExisting = True ... This modified version of your script will inform you if there ...
    (microsoft.public.scripting.vbscript)