开发者

Add list of computers to domain group

开发者 https://www.devze.com 2022-12-21 12:35 出处:网络
this is probably pretty simple, but I\'ve got this text file containing a bunch of computernames that I want to add as members of a certain AD Group.

this is probably pretty simple, but I've got this text file containing a bunch of computernames that I want to add as members of a certain AD Group. Thing is, I don't know the CN or full path of the computer names, because the computers may lie on three different OUs in the Domain structure.

So, I the code I've got so far is this (strLine is the short computername):

con开发者_StackOverflowtents = textFile.ReadAll
arrLines = Split(contents,vbCrLf)

For Each strLine in arrLines
  AddToGroup strLine
next

textFile.Close

And the function 'AddToGroup' isn't created yet. Basically, this needs to take the argument (strLine) and look up the computername to get the full CN Name. And then add it to the AD group.

This is probably pretty basic, but my head is kinda full right now.. :(


Nevermind, got it to work myself by finding out the CN prior to the other script. Like this:

Set ADSys = CreateObject("ADSystemInfo")
FullCN = ADSys.ComputerName
0

精彩评论

暂无评论...
验证码 换一张
取 消