Mega_Demon
03-07-2014, 16:32
Добрый день, есть скрипт, который добавляем в политику на юзера и получаем следующие данные в описание компьютера
Система (Hewlett-Packard HP Pro3500 Series) Logged on: ЮЗЕР 03.07.2014 8:32:48
Вместо имени пользователя, скрипт прописываем имя компьютера.
Сам скрипт, скрипт не мой нашел на просторах интернета, AD 2008, пользовательские машинки Windows 7
прошу помощи :)
On Error Resume Next
Dim adsinfo, ThisComp, oUser
Set adsinfo = CreateObject("adsysteminfo")
Set ThisComp = GetObject("LDAP://" & adsinfo.ComputerName)
Set oUser = GetObject("LDAP://" & adsinfo.UserName)
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
' Get service tag and computer manufacturer
For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")
Next
' Get computer model
For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")
model = trim(replace(objComputer.Model, ",", "."))
Next
' Get computer object in AD
Set objSysInfo = CreateObject("ADSystemInfo")
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
' Build up description field data and save into computer object if different from current description
' We also do not update computers with a description that starts with an underscore (_)
newDescription = WshNetwork.UserName & "(" & manufacturer & " " & model & ") Logged on: " + oUser.cn + + CStr(Now)
if not objComputer.Description = newDescription and not left(objComputer.Description,1) = "_" then
objComputer.Description = newDescription
objComputer.SetInfo
end if
Система (Hewlett-Packard HP Pro3500 Series) Logged on: ЮЗЕР 03.07.2014 8:32:48
Вместо имени пользователя, скрипт прописываем имя компьютера.
Сам скрипт, скрипт не мой нашел на просторах интернета, AD 2008, пользовательские машинки Windows 7
прошу помощи :)
On Error Resume Next
Dim adsinfo, ThisComp, oUser
Set adsinfo = CreateObject("adsysteminfo")
Set ThisComp = GetObject("LDAP://" & adsinfo.ComputerName)
Set oUser = GetObject("LDAP://" & adsinfo.UserName)
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
' Get service tag and computer manufacturer
For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")
Next
' Get computer model
For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")
model = trim(replace(objComputer.Model, ",", "."))
Next
' Get computer object in AD
Set objSysInfo = CreateObject("ADSystemInfo")
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
' Build up description field data and save into computer object if different from current description
' We also do not update computers with a description that starts with an underscore (_)
newDescription = WshNetwork.UserName & "(" & manufacturer & " " & model & ") Logged on: " + oUser.cn + + CStr(Now)
if not objComputer.Description = newDescription and not left(objComputer.Description,1) = "_" then
objComputer.Description = newDescription
objComputer.SetInfo
end if