|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Machine Account Group Membership: How to...
Hello, I have been looking all over, and I can't seem to find anything
close to what I need. I am looking for a way to run a script that executes something based on the Machine Account group membership. So, the logic would be something like: if MACHINEACCOUNT is member of group "XP Machines" run job.bat else run otherjob.bat Sorry for my poor skills shown there! I really don't know much about scripting, and the little I can figure out can't get me what I need. also, I would really prefer it to run in a batch file, because that is how it is all set up already. I really appreciate any help from anyone! Thanks much! <rmfis***@aquadog.net> wrote in message
Show quote news:1191638250.945873.289190@o80g2000hse.googlegroups.com... Testing for computer group membership is just like for user group > Hello, I have been looking all over, and I can't seem to find anything > close to what I need. I am looking for a way to run a script that > executes something based on the Machine Account group membership. So, > the logic would be something like: > > if MACHINEACCOUNT is member of group "XP Machines" > run job.bat > else > run otherjob.bat > > Sorry for my poor skills shown there! I really don't know much about > scripting, and the little I can figure out can't get me what I need. > also, I would really prefer it to run in a batch file, because that is > how it is all set up already. > > I really appreciate any help from anyone! Thanks much! > membership. To do this in a batch file you need a third party tool. I believe the IfMember utility is available on the Microsoft web site (it used to be in the NT resource kit). There is also a product called KiXstart. In VBScript you would bind to the computer and group objects, then use the IsMember method of the group. For example: ============== ' Bind to computer object. Set objComputer = GetObject("LDAP://cn=TestComputer,ou=West,dc=MyDomain,dc=com") ' Bind to group object. Set objGroup = GetObject("LDAP://cn=MyGroup,ou=West,dc=MyDomain,dc=com") ' Test for membership in the group. If (objGroup.IsMember(objUser.AdsPath) = True) Then ' Do something. End If ============ Usually the computer is the local computer, not a remote machine. For example, this is often done in a logon script. To bind to the local computer use: =========== ' Retrieve DN of local computer from ADSystemInfo object. Set objSysInfo = CreateObject("ADSystemInfo") Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName) ========= To run another program from VBScript, you can use the Run method of the Shell object. For example: ========= Set objShell = CreateObject("Wscript.Shell") objShell.Run("%comspec% /c c:\Scripts\job.bat", 0) ========= I hope this helps. |
|||||||||||||||||||||||