我有一个在2003R2和2008R2上托pipe的广告,当用户使用该计算机(例如compA)login并在脚本中执行某些操作时,我想检查域计算机(例如,compA)的成员资格。 我认为WMI可能是有用的,但我无法find正确的查询来获得有问题的计算机帐户的组列表。 任何想法?
Get-WmiObject win32_ComputerSystem | 格式 – 列表DomainRole
0"Stand Alone Workstation" 1"Member Workstation" 2"Stand Alone Server" 3"Member Server" 4"Back-up Domain Controller" 5"Primary Domain Controller"
这是我从这个网站修改的脚本。 我没有testing过这个代码,但是看起来很好听。
Option Explicit Dim objNetwork, strDomain, strComputer, objComputer, objGroup, strGroupMemberships Dim arrGroupMemberships ' Get the domain and username from the WScript.Network object Set objNetwork = CreateObject("WScript.Network") strDomain = objNetwork.UserDomain strComputer = objNetwork.ComputerName ' Instanciate the user object from the data above Set objComputer = GetObject("WinNT://" & strDomain & "/" & strComputer) ' Run through the users groups and put them in the string For Each objGroup In objComputer.Groups strGroupMemberships = strGroupMemberships & objGroup.Name & "," Next arrGroupMemberships = Split(strGroupMemberships, ",") ' Loop through array to get groups that this computer is a member of
如果你现在还没有解决的话,这应该让你朝着正确的方向前进。