I want to try to use SIDTONAME against a remote computer to create a group of select statements that will allow me to try a few different passwords for the Local Administrators account that we have on different systems.
I'm not sure this can be done this method or not and I'm looking to see if anyone can confirm whether or not it can be done via this method.
In cases where the Administrator account has been renamed I'd like to use SIDTONAME to check it. This is an Administrator script, not a logon script.
code:
break on
$wksta = 'computer1'
? 'Now attaching to: '+'\\'+$wksta
SELECT
CASE LocalAdmin('\\'+$wksta)
? 'You have admin rights on '+$wksta
CASE NOT LocalAdmin('\\'+$wksta)
USE V: '\\'+$wksta+'\C$' /user:$wksta+'\Administrator' /password:'password'
; The above line works but I want to use the line below in case the account
; has been renamed.
$x = $wksta+'\'+sidtoname('S-1-5-32-500')
USE V: '\\'+$wksta+'\C$' /user:$x /password:'password'
? 'Error mapping was: '+@ERROR+' - '+@SERROR
IF @ERROR = 0
? 'You successfully mapped the C$ share as an admin - run code'
ELSE
? 'You were unable to map the C$ share as an admin - can not run code'
ENDIF
CASE 1
? 'Unable to map as an Administrator'
ENDSELECT
function LocalAdmin($wksta)
$LocalAdmin=ingroup('$wksta\'+sidtoname('S-1-5-32-544'))-1+@inwin
endfunction