On Error Resume Next

Set fso = CreateObject("scripting.filesystemobject")
Set f = fso.OpenTextFile("Hosts.txt", 1)
Set r = fso.OpenTextFile("Result.txt", 2, True)

Do While f.AtEndOfStream = False
       t = f.ReadLine
       r.WriteLine t & "-------------"
       Set obj = GetObject("WinNT://" & t & "/Administrators, Group")
       For Each i In obj.Members
               r.WriteLine "        " & i.Name
       Next
       Set obj = Nothing
Loop

f.Close
r.Close
Set f = Nothing
WScript.Echo "Done!"

和vbs在同一目录下, 准备一个名为Hosts.txt的文本文档, 内容格式为一行一个计算机名或ip就行.
运行后会自动生成一个result.txt文本, 里面即为admin组成员.


Powershell


$accounts=gwmi win32_useraccount -computername +电脑名
foreach($account in $accounts){
$accountinfo=New-Object psObject|select account,group,Disabled
$accountinfo.account=$username=$account.name
$user= [adsi]"WinNT://$env:computername/$username,user"
$accountinfo.group=$user.Groups()|%{$_.GetType().InvokeMember("Name",'GetProperty',$null,$_,$null)}
$accountinfo.Disabled=$account.Disabled
$accountinfo
}


有高手知道Powershell如何来获取吗?有知道的高手还请多多指教。