将本地计算机描述写入 AD
Write local Computer Description to AD
我有一个脚本可以将特定文本写入:
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
srvcomment
然后我想要的是要发送到 Active Directory 计算机描述的注册表项。
如果需要,我可以将该注册表项提取到文本或 CSV 文件中。
我也可以使用以下方式写入活动目录:
Option Explicit
Dim objSysInfo, strComputerDN, objComputer, strDescr
' Retrieve DN of local computer object in AD.
Set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
' Bind to the computer object in AD.
Set objComputer = GetObject("LDAP://" & strComputerDN)
' Assign description and save.
objComputer.description = "test2"
objComputer.SetInfo
但是,这只会输入您所写的内容:
objComputer.description = "test2"
我想要做的是从注册表中提取信息并将其发送到 Active Directory。
你唯一缺少的是 reading the value from the registry:
...
Set objShell = WScript.CreateObject("WScript.Shell")
objComputer.description = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\srvcomment")
...
我有一个脚本可以将特定文本写入:
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
srvcomment
然后我想要的是要发送到 Active Directory 计算机描述的注册表项。
如果需要,我可以将该注册表项提取到文本或 CSV 文件中。
我也可以使用以下方式写入活动目录:
Option Explicit
Dim objSysInfo, strComputerDN, objComputer, strDescr
' Retrieve DN of local computer object in AD.
Set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
' Bind to the computer object in AD.
Set objComputer = GetObject("LDAP://" & strComputerDN)
' Assign description and save.
objComputer.description = "test2"
objComputer.SetInfo
但是,这只会输入您所写的内容: objComputer.description = "test2"
我想要做的是从注册表中提取信息并将其发送到 Active Directory。
你唯一缺少的是 reading the value from the registry:
...
Set objShell = WScript.CreateObject("WScript.Shell")
objComputer.description = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\srvcomment")
...