You da man Mr. Bullock. This is how I changed the code based off of your reccomendations. Let me know if this looks better please. I'm only asking because I like to code efficiently. Thanx again Mr. Bullock.
Code:
$AllowedGroups = "Administrator",Domain Admins"
$NetworkServer = "\\LogServer"
$NetworkShare = "ScriptLog"
$OutputFile = 'Unauthorized Accounts in local Administrators Group.log'
$handle = FreeFileHandle()
$count = 0
Dim $unauthAccounts
$ = Open($handle,$NetworkServer+'\'+$NetworkShare+'\'+$OutputFile,5)
While @ERROR = -3 AND $count < 100
$ = Open($handle,$NetworkServer+'\'+$NetworkShare+'\'+$OutputFile,5)
$count = $count + 1
Loop
$objComputer = GetObject("WinNT://"+@WKSTA)
$objComputer.Filter = "Group",""
For Each $objGroup in $objComputer
$Group = GetObject("WinNT://"+@WKSTA+"/"+$objGroup.Name)
If $objGroup.Name = 'Administrators'
For Each $Member in $Group.Members
If AScan($AllowedGroups,$Member.Name) = -1
ReDim preserve $unauthAccounts[Ubound($unauthAccounts)+1]
$unauthAccounts[ubound($unauthAccounts)] = $Member.Name
Endif
Next
for each $x in $unauthAccounts
? $x
next
;$ = WriteLine($handle,@WKSTA+', '+$objUser.Name+', '+@DATE+', '+@TIME+@CRLF)
Endif
Next
$ = Close($handle)
'done'
get $