Re: unable to sucessfully run the change local administrator scrip



Your suggestion is very cool (net.exe)..... how do i apply this script?...I
saved it as a bat file, created a GPO and applied it to top level domain...
but it didnt work....
Please bear with me, i never used GPO policy.... i looked at the policy
using GPMC which is very cool too... it seems to be applied correctly .. I
applied it to Domain computers... That would cover all machines correct?

thank you...

"Torgeir Bakken (MVP)" wrote:

> davisr65 wrote:
>
> > I copied a script from "The Scripting Guy from microsoft technet's website
> > that when executed, will change the local admin password of all pc's in an OU
> > the following is the script:
> > Set objOU = GetObject("LDAP://OU=RAD, DC=vehma, DC=com")
> > objOU.Filter = Array("Computer")
> >
> > For Each objItem in objOU
> > strComputer = objItem.CN
> > Set objUser = GetObject("WinNT://" & strComputer & "/Administrator")
> > objUser.SetPassword("test123")
> > Next
> > The following message appears when i run it from a Domain controller:
> > Line 5
> > char 5
> > error: the network path was not found
> > code: 80070035
> > source : (null)
> > thanks
> Hi,
>
> Much easier and safer to do this in a computer startup script if
> you ask me.
>
> 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
> batch file will set the password on the account:
>
> '--------------------8<----------------------
> @echo off
> net.exe user administrator newpassword
> '--------------------8<----------------------
>
>
> 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 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 should 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.ComputerName & "/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/scriptcenter/default.mspx
>
.



Relevant Pages

  • Re: Script for renaming and changing PWD on Local Admin Account
    ... "Sandra L Miller" wrote: ... If you only have one administrator account on each machine, ... > out there from which I built this script; ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Synchornize date script
    ... I create an account called schedule, ... because the user doesnt have permission to modify the date, because with a user with admin rights, the script works just fine. ... The least safe approach is to use logon scripts, as you must use alternate credentials which exposes the administrator password. ...
    (microsoft.public.scripting.vbscript)
  • Re: How to verify whether an account is admin or not?
    ... OK Doug, but my name was rejected and it was the software that suggested NET ... can you throw any light on the Administrator being shown as "SUPPORT ... An error has occcurred in the script on this page. ... shows guest account off. ...
    (microsoft.public.windows.mediacenter)
  • Re: Changing Workstation passwords
    ... You could do it in a computer startup script that runs ... oUser.SetPassword sNewPassword ... "Administrator" (e.g. the account is renamed, ... Dim sUserSID, oWshNetwork, oUserAccount ...
    (microsoft.public.windowsxp.security_admin)
  • RE: Cannot send SMTP mail using Administrator account after SP1 for Ex
    ... Hello Noel, ... you don't use "The" Administrator user account. ... more you'll risk exploitation if someone or something accesses the script ...
    (microsoft.public.windows.server.sbs)