Here's my script right now:
Code:
Break ON
$ = SetOption("WrapAtEOL","ON")
$ = SetOption("ASCII","On")
$server = "\\SERVER\Logging\"
$folder = "Local_Admin_Password_Log\"
$file = "PasswordLog.log"
$comp = @WKSTA
$rc = WshPipe("%COMSPEC% /e:1024 /c net user wsadmin /random /passwordchg:yes")
$y = 0
while @ERROR = 0 ;1
for each $line in $rc ;2
if instr($line, "Password for") ;3
while $y = 0 ;4
if Open(5,$server+$folder+$file,5) = 0
$line2 = ReadLine(5)
do ;5
? "$line2"
if instr($line2,"$comp")
? "evals true"
endif
; $line = substr($line,26,len($line))
; $temp = WriteLine(5,"$comp,$line,"+@TIME+","+@DATE+@CRLF)
; $ = Close(5)
; $y = 1
until @ERROR = -1
else
$y = 0
Sleep 1
endif
loop
endif
next
loop
1: My attempt to loop through the password reset command if it doesn't meet our network's password complexity constraints.
2: Get the information from the command line password change
3: Check to see if the password change was successful
4: My attempt at looping through opening a file to make sure that it's not locked
5: My attempt to loop through reading the password log file to see if the computer running the script already has an entry and if it does, replace it. -- This is where I'm having my problems. Right now, $line2 never holds a value and my conditional in the last loop that uses instr() never evals to true. Please feel free to critique/destroy the rest of my script it it needs to be. Thanx in advance guys!