Jump to content


  • 0
Tjindarr

Task sequence command

Question

2 answers to this question

Recommended Posts

  • 0

Is there a way to add a computer to a security group with the help of the windows 7 installation task sequence?

 

 

I found this when i googled abit but im not to familiar with scripts... where do i input our domain and group information?

 

 

 

Const ADS_PROPERTY_APPEND = 3

 

 

Set WshShell = WScript.CreateObject("WScript.Shell")

 

'----Get Computer DN------

Set objADSysInfo = CreateObject("ADSystemInfo")

ComputerDN = objADSysInfo.ComputerName

strcomputerdn = "LDAP://" & computerDN

Set objADSysInfo = Nothing

 

'----Connect AD-----

Set oRoot = GetObject("LDAP://rootDSE")

strDomainPath = oRoot.Get("defaultNamingContext")

Set oConnection = CreateObject("ADODB.Connection")

oConnection.Provider = "ADsDSOObject"

oConnection.Open "Active Directory Provider"

 

'-----Read commandline---

Set args = WScript.Arguments

 

For i = 0 To Args.Count - 1

'wscript.echo Args.Item( i )

addgroup Args.Item( i )

next

 

 

Function Addgroup(groupname)

'----Get Group DN------

 

Set oRs = oConnection.Execute("SELECT adspath FROM 'LDAP://" & strDomainPath & "'" & "WHERE objectCategory='group' AND " & "Name='" & GroupName & "'")

If Not oRs.EOF Then

strAdsPath = oRs("adspath")

End If

 

Set objGroup = GetObject (stradspath)

Set objComputer = GetObject (strComputerDN)

 

If (objGroup.IsMember(objComputer.AdsPath) = False) Then

objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array(computerdn)

objGroup.SetInfo

End If

 

End Function

Share this post


Link to post
Share on other sites

  • 0

Got it sorted out. was to quick and didnt read the guide i found carefully enough the script is finished as it is.

 

Just add it to a task sequence just after the SCCM client installation and run it as an account with the proper permission.

"filename.vbs" adgroup1 adgroup2 adgroup3

 

Found all this here http://ccmexec.com/?p=364

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.