I have the following script that will give me all computer accounts that
have not had a password changed in a number of days, how can i get it so the
script can write this to a text file for editing...

Thanks
Gavin...

On Error Resume Next

DomainString=InputBox("Enter the domain name","Check Active
Computers","DomainName")

If DomainString="" Then

WScript.echo "No domain specified or script cancelled."

WScript.quit

End If

numDays=InputBox("What is the number of days to use as a cutoff for Active
Computer Accounts?","Check Active Computers","XX")

If numDays="" Then

WScript.echo "No cutoff date specified or script cancelled."

WScript.quit

End If

Set DomainObj = GetObject("WinNT://"&DomainString)

If err.number<>0 Then

WScript.echo "Error connecting to " & DomainString

WScript.quit

End If

DomainObj.Filter = Array("computer")

WScript.echo "Computer Accounts in " & DomainString & " older than " &
numDays & " days."

For Each Computer In DomainObj

Set Account = GetObject("WinNT://" & DomainString & "/" & Computer.Name &
"$")

RefreshTime = FormatNumber((Account.get("PasswordAge"))/86400,0)

If CInt(RefreshTime) >= CInt(numDays) Then

WScript.echo "**DELETE** " & Computer.Name & " Password Age is " &
RefreshTime & " days."

End If

Next

Set DomainObj=Nothing

Set Shell=Nothing

WScript.quit

Re: copy results to a text file by trading_jacks

trading_jacks
Fri Oct 13 15:36:08 CDT 2006

***add these to to top of the script
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TextFile = FSO.OpenTextFile("C:\info.txt", 8, True)

*** add this after the echo command
TextFile.Writeline Computer.Name & VBTab & RefreshTime

this will give you a tab separated list you can open in excel.


Re: copy results to a text file by Richard

Richard
Fri Oct 13 19:01:12 CDT 2006

Also, since the script echos to the console, you can run the script at a
command prompt and redirect the output to a text file. For example, if your
script is in a file called OldComputers.vbs, you can create a text file with
the results called report.txt with the following command:

cscript //nologo OldComputers.vbs > report.txt

This assumes that you are in the directory where the file OldComputers.vbs
is saved. If not, include the path to the file. The //nologo option
suppresses WSH logo information.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net