[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Local Admin password change script gives and network error.

Posted on 2009-02-14
2
Medium Priority
?
312 Views
Last Modified: 2012-05-06
Hi,

Local Admin password change script gives and network error.
Can any one add the error check options for

no permission
Timedout
or any other issue it has to log that and proceed.

Regards
Sharath
Const ForAppending = 8
Const ForReading = 1
 
Set fso=CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("C:\pass_changed.txt")
Set objNetwork = CreateObject("Wscript.Network")
 
Set objFile=fso.OpenTextFile("C:\computers.txt", ForReading)
 
Do Until objFile.atEndofStream
     strComputer = objFile.ReadLine
    
Set objUser = GetObject("WinNT://" & strComputer & "/administrator")
 
intPasswordAge = objUser.PasswordAge
intPasswordAge = intPasswordAge * -1 
dtmChangeDate = DateAdd("s", intPasswordAge, Now)
 
objTextFile.WriteLine "Password for " & strComputer & " was last changed: " & dtmChangeDate
Loop

Open in new window

0
Comment
Question by:bsharath
2 Comments
 
LVL 47

Accepted Solution

by:
Donald Stewart earned 2000 total points
ID: 23641382
Try this,

Now any error met the script will just continue on  to the next

Const ForAppending = 8
Const ForReading = 1
 On Error Resume Next
Set fso=CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("C:\pass_changed.txt")
Set objNetwork = CreateObject("Wscript.Network")
 
Set objFile=fso.OpenTextFile("C:\computers.txt", ForReading)
 
Do Until objFile.atEndofStream
     strComputer = objFile.ReadLine
    
Set objUser = GetObject("WinNT://" & strComputer & "/administrator")
 
intPasswordAge = objUser.PasswordAge
intPasswordAge = intPasswordAge * -1 
dtmChangeDate = DateAdd("s", intPasswordAge, Now)
 
objTextFile.WriteLine "Password for " & strComputer & " was last changed: " & dtmChangeDate
Loop

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 23641628
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month20 days, 9 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question