use Win32::TieRegistry( Delimiter=>"#" ); use Win32; $nodename = $ENV{COMPUTERNAME}; $domain = "dpcdom"; @node_list = ("adledsu11", "adldpca03","dpc011510141", dpc011510143", "dpc011510157"); foreach $node (@node_list) { print "\n$node\n"; undef $hkey_connect; $Register = "SYSTEM#CurrentControlSet#Control#ProductOptions"; if ($nodename eq $node) { $hkey_connect = $Registry->{"LMachine#"}; } else { $hkey_connect = $Registry->Connect($node, "LMachine#", {Access=>KEY_READ}); } if ($hkey_connect) { print "successful connection to $node ...\n"; $server_role = $hkey_connect->{"$Register#ProductType"}; print " server_role is $server_role\n"; # # # Get Administrator account text SID if ($server_role eq "Primary Domain Controller" or $server_role eq "Domain Controller") { Win32::LookupAccountName("\\\\$node", $domain, $garbage, $sid, $sid_type); } else { Win32::LookupAccountName("\\\\$node", $node, $garbage, $sid, $sid_type); } my $text_sid = "default"; # $text_sid = SID_bin2text($sid); print " text_sid is $text_sid\n"; } else { print "unable to connect to registry!\n"; } } sub SID_bin2text { my($bin) = @_; my ($Revision, $SubAuthorityCount, @IdentifierAuthorities) = unpack("CCnnn", $bin); ($IdentifierAuthorities[0] || $IdentifierAuthorities[1]) and return; my($temp, $temp2, @SubAuthorities) = unpack("VVV$SubAuthorityCount",$bin); return "S-$Revision-$IdentifierAuthorities[2]-".join("-",@SubAuthorities); }