Skip to content

Join computer to AD Security Group using .vbs during OS Task Sequence

Featured Replies

Hi

 

I am using SCCM 2007 R3 and I am deploying Windows 7 x64 with SP1.

 

I want to Add the computer to the security group of AD.

 

I have created the .vbs script as below

 

Option Explicit

 

Dim objSysInfo, objComputer, strComputerDN

Dim objComputerGroup

 

' Retrieve DN if user and local computer.

Set objSysInfo = CreateObject("ADSystemInfo")

strComputerDN = objSysInfo.ComputerName

 

' Bind to user and computer objects.

Set objComputer = GetObject("LDAP://" & strComputerDN)

 

' Bind to groups. You must specify the full Distinguished Names.

Set objComputerGroup = GetObject("LDAP://CN=IndiaDesktopgroup,OU=Desktops,OU=COmputers,OU=India,DC=mydomain,DC=local")

 

' Add user and computer to groups, if not already members.

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

objComputerGroup.Add(objComputer.AdsPath)

End If

 

 

1.I have tried creating package and added progrgram into it and use that program into task sequence

2. I have also tried Adding command line in task sequence but didnt help. and error comes "incorrect function"

 

Pls see the below task sequence and error log

 

post-15600-0-94094200-1334206069_thumb.png

 

post-15600-0-75527700-1334206071_thumb.png

Hi,

In your scenario above the script will be executed using the System Account on the client compouter which doesn't have permission in AD, so I would start by using a service account with the neceserray permissions.

Check out the script I use to achieve the same thing, there is a description on how to implement it as well.

http://ccmexec.com/2010/08/adding-computer-to-ad-groups-during-deployment/

regards,

Jörgen

  • Author

Hi

 

I have created a package called "SCCmScripts" and not added any program into and give the UNC path where the .vbs script is located.

 

I have applied your script but still get the error "incorrect function".

 

Pls see the below screenshots.

 

 

 

post-15600-0-45884200-1334216554_thumb.png

 

post-15600-0-79677700-1334216557_thumb.png

 

post-15600-0-16853000-1334216802_thumb.png

  • Author

Hi Peter,

 

 

The script works fine when i run manually from the workstattion.

 

 

Also I am using standard task sequence and not using MDT task sequence.

 

 

Thanks

  • Author

Hi Jorgen,

 

1. Yes , I am running the script after logging into the desktop with the same account after OS is deployed.

 

2. What is the error mean "incorrect function" when\why it comes.

 

 

Thanks

Prakash

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.