因應能源費用高漲響應綠色節能概念
你知道網路上有多少台電腦是開機不幹事嗎?
尤其是晚上夜深人靜時 大家都下班了還有多少台電腦是不關機的呢?
分享兩個做法讓你很容易就能知道
方法一:
使用IPScan 工具掃描網段內IP 輸出成 csv檔用Excel開啟
例如: ipscan 10.66.21.0 10.66.24.254 scan.csv -f:csv
掃描 10.66.21.0 至 10.66.24.0 4個Class C 網段(也可定義掃描特定Port是否開啟) ;輸出如下
10.66.21.1,Dead,N/S,N/S
10.66.21.2,Dead,N/S,N/S
10.66.21.3,Dead,N/S,N/S
10.66.21.4,Dead,N/S,N/S
10.66.21.5,0 ms,N/A,N/A
10.66.21.6,0 ms,N/A,N/A
10.66.21.7,0 ms,N/A,N/A
下載網址: http://www.angryziber.com/w/Home
第二種方法
需有Domain Admin 權限執行 Cscript.exe ***.vbs
詳盡方法為 到Domain AD中找出所有電腦帳號
再ping 電腦看是否有回應 若有回應再用WMI功能找出是誰登入此電腦
請參考 http://www.microsoft.com/technet/scriptcenter/default.mspx
以下為vbs程式碼 請複製後存成 *.vbs 修改網域名稱 後可執行
輸出為 時間.xls(例如:2008523下午1203.xls)
On error resume next
filename=mid(now,1,4)&mid(now,6,instrRev(now,"/")-instr(now,"/")-1)&mid(now,instrRev(now,"/")+1,instr(now," ")-instrRev(now,"/")-1)&mid
(now,instr(now," ")+1,2)&mid(now,instrRev(now," ")+1,2)&mid(now,instrRev(now," ")+4,2)&".xls"
ComputerCount=0
Const ADS_SCOPE_SUBTREE = 2
Set fso = CreateObject("Scripting.FileSystemObject")
Set upgrade = fso.CreateTextFile("./"&filename)
strDomainDn="dc=xxx,dc=xxx"
'strDomainDn = InputBox("Enter the DN of your domain." & vbCrLf & "(i.e. dc=domain,dc=com)")網域名稱
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from 'LDAP://" & strDomainDn & "' " _
& "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strComputer = objRecordSet.Fields("Name").Value
Set objShell = CreateObject("WScript.Shell")
strCommand = "%comspec% /c ping -n 3 -w 2000 " & strComputer & ""
Set objExecObject = objShell.Exec(strCommand)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadAll()
If Instr(strText, "bytes=32") > 0 Then
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_OperatingSystem")
Set colItems3 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in ColItems
strOS = objItem.Caption
Next
For Each objItem in colitems3
strUserName = objItem.Username
Next
If Err.Number > 0 then
strErrorSystems = strComputer & ", " & strErrorSystems
Else
ComputerCount=ComputerCount+1
upgrade.Write strComputer & " 使用者帳號: " & strUserName & " 電腦IP: " & mid(strText,Instr(strText, "from")
+5,Instr(strText, "bytes=32")-Instr(strText, "from")-7) & " 作業系統: " & strOS &" 時間: "&now & vbCrLf
' End If
End If
'flushes error code from the previous loop
Err.Clear
Else
UnavailableSystems = strComputer & ", " & UnavailableSystems
End If
Loop
objRecordSet.MoveNext
Loop
upgrade.close