自动更新电脑description的logon/logoff Script

可以设为登录脚本,该脚本会自动更新电脑描述,在域控制器的电脑和用户管理里面可以看到该电脑的登录用户名,登录时间,电脑品牌,型号,序列号)可用与开机登录脚本,登录登出组策略
Logn Script

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")
'biosversion = replace(objSMBIOS.SMBIOSAssetTag, ",", ".")
Next

For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")
model = trim(replace(objComputer.Model, ",", "."))
Next

Set objSysInfo = CreateObject("ADSystemInfo")
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)

if NOT objComputer.Description = WshNetwork.UserName & " (" & serviceTag & " - " & manufacturer & " " & model & ")" then
objComputer.Description = "User: " & WshNetwork.UserName & " | Logged on: " & Now() & " (" & serviceTag & " - " & manufacturer & " " & model & ")"
objComputer.SetInfo
end if

Log off Script

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")
Next

For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")
model = trim(replace(objComputer.Model, ",", "."))
Next

Set objSysInfo = CreateObject("ADSystemInfo")
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)

if NOT objComputer.Description = WshNetwork.UserName & " (" & serviceTag & " - " & manufacturer & " " & model & ")" then
objComputer.Description = "User: " & WshNetwork.UserName & " | Logged off: " & Now() & " (" & serviceTag & " - " & manufacturer & " " & model & ")"
objComputer.SetInfo
end if

打赏

共有 0 条评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注