vbscript will not work from task sequence
-
Saturday, December 08, 2012 2:26 AM
I am trying to run a vbscript from the task sequence using the "Run command line" task with the "run as this account" box checked. It does not work in the task sequence, but it will work when logged onto the target PC after install when logged in with the same credentials. I found this, but it didn't work. I tried finding posts about adding domain credentials to vbscript, but my understanding of this language is minimal (I got the script from somewhere else.) Can anyone provide me with the code to add domain credentials to this script? My test domain info is as follows:
Domain: testdeploy.com
Primary DC: Win2k8R2DC.testdeploy.com
Domain User: BuildAccount
Domain User password: Secret123
Domain user OU: OU=Deployment,DC=testdeploy,DC=com
'Get MachineObjectOU Value Set wshNetwork = CreateObject("WScript.Network") Set oFso = CreateObject("Scripting.FileSystemObject") Set objSysInfo = CreateObject( "ADSystemInfo" ) Set ArgObj = WScript.Arguments 'Use first argument as target OU strMachineObjectOU = ArgObj(0) strComputerDN = objSysInfo.ComputerName nComma = InStr(strComputerDN,",") strCurrentOU = Mid(strComputerDN,nComma+1) strComputerName = Left(strComputerDN,nComma - 1) 'If current ou is different than target OU. Move object If UCase(strCurrentOU) <> UCase(strMachineObjectOU) Then Set objNewOU = GetObject("LDAP://" & strMachineObjectOU) Set objMoveComputer = objNewOU.MoveHere("LDAP://" & strComputerDN, strComputerName) End If
- Edited by Zerrith Saturday, December 08, 2012 2:28 AM
All Replies
-
Saturday, December 08, 2012 4:23 AM
It does not work in the task sequence
Please provide some more detail...
Is an error message generated?
What logging is performed?
What logs have you examined?
At what point in the task sequence are you executing this step? (before, or after the Setup Windows & ConfigMgr step?)
In what environment (WinPE or FullOS)?Check the execmgr.log and smsts*.logs - what parameters were passed to execmgr and, are they as expected by you, and what was the return code?
I'm also guessing that the purpose of the script is to move the computer account where this is being executed, but it would be useful to know if that's an accurate guess or not...
EDIT: oops, sorry, I just realised you are using MDT not ConfigMgr.. but most of the questions are still applicable.
Don
(Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable.
This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!)- Edited by Don - tesgroupMicrosoft Community Contributor Saturday, December 08, 2012 4:24 AM
-
Saturday, December 08, 2012 2:44 PM
Do you run it with cscript.exe infront of it? place in in the Share\scripts folder and try as a command line
cscript.exe "%scriptroot%\myscript.extension" as your command line, and look a the bdd.log for any reasons it failed.
-
Saturday, December 08, 2012 5:06 PM
The script is used to move the computer account from the staging OU I use during deployment (to keep the interactive logon message from displaying during deployment) to the proper OU. The task is run directly after the Apply local GPO package task at the very end of the task sequence. I looked in the smsts log and found the following entry for the task in question:
Start executing an instruciton. Instruction name: MoveOU. Instruction pointer: 71 TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set a global environment variable _SMSTSCurrentActionName=MoveOU TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set a global environment variable _SMSTSNextInstructionPointer=71 TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set a local default variable PackageID TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set a local default variable RunAsUser TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set a local default variable SMSTSRunCommandLineUserName TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set a local default variable SMSTSRunCommandLineUserPassword TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set a local default variable LoadProfile TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set a global environment variable _SMSTSLogPath=C:\Users\ADMINI~1\AppData\Local\Temp\SMSTSLog TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Expand a string: %TOOLROOT%\bddrun.exe /runas cscript.exe %SCRIPTROOT%\MoveOU.vbs "OU=Test OU,DC=testdeploy,DC=com" TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Expand a string: TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Command line for extension .exe is "%1" %* TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Set command line: %TOOLROOT%\bddrun.exe /runas cscript.exe %SCRIPTROOT%\MoveOU.vbs "OU=Test OU,DC=testdeploy,DC=com" TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Start executing the command line: %TOOLROOT%\bddrun.exe /runas cscript.exe %SCRIPTROOT%\MoveOU.vbs "OU=Test OU,DC=testdeploy,DC=com" TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) !--------------------------------------------------------------------------------------------! TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Expand a string: WinPEandFullOS TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Executing command line: %TOOLROOT%\bddrun.exe /runas cscript.exe %SCRIPTROOT%\MoveOU.vbs "OU=Test OU,DC=testdeploy,DC=com" TSManager 12/8/2012 9:42:30 AM 3032 (0x0BD8) Process completed with exit code 1 TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8) !--------------------------------------------------------------------------------------------! TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8) Failed to run the action: MoveOU. Incorrect function. (Error: 00000001; Source: Windows) TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8) Sending status message . . . TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8) Executing in non SMS standalone mode. Ignoring send a task execution status message request TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8) Set a global environment variable _SMSTSLastActionRetCode=1 TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8) Set a global environment variable _SMSTSLastActionSucceeded=false TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8) Clear local default environment TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8) The execution engine ignored the failure of the action (MoveOU) and continues execution TSManager 12/8/2012 9:42:31 AM 3032 (0x0BD8)
-
Sunday, December 09, 2012 11:23 AM
You'll be logged in to the machine as a local admin, correct? Are you using the "run this step as the following account" option when running that script?
The local admin account won't have rights to move objects about in AD so you will have to run that action as an authenticated user - "BuildAccount" in this instance.
Remember that just because you may be using "BuildAccount" as the account to connect to mapped drives with, actions still run as the current user ( local admin) on the local machine.
-
Sunday, December 09, 2012 5:37 PMThe script works when logged in as the BuildAccount after the install. It does not work when run in the task sequence with "run as different account" checked. I am looking for a way for the script itself to use different credentials.
-
Monday, December 10, 2012 3:21 PM
It seems as iff the script is looking for a command line argument to be passed in, for example:
cscript %SCRIPTROOT%\MyScript.vbs OU=Deployment,DC=testdeploy,DC=com
are you doing that? Or am I misunderstanding the script? If so, its probably a parsing problem, missing or incorrect quoatation marks. Incorrect Function 00000001 errors are usually syntax or command entry problems, the task doesn't understand what you want it to do.
I have a few tasks that take command line input through variables, they work fine, but you have to quote them right.
-
Monday, December 10, 2012 10:04 PM
I have been struggling with the same script for days.
Tried all possible places for quotation marks but it always fail.Like Zerrith is saying it works fine executed manually in the command prompt like this:
cscript C:\MyScript.vbs OU=Deployment,DC=testdeploy,DC=comBut not like this from the task sequence:
cscript %SCRIPTROOT%\MyScript.vbs OU=Deployment,DC=testdeploy,DC=com
cscript "%SCRIPTROOT%\MyScript.vbs OU=Deployment,DC=testdeploy,DC=com"
cscript "%SCRIPTROOT%\MyScript.vbs" "OU=Deployment,DC=testdeploy,DC=com"
cscript "%SCRIPTROOT%\MyScript.vbs" OU=Deployment,DC=testdeploy,DC=comThe script comes from here:
blog coretech dk/jgs/vbscript-move-computer-object-to-another-ou-via-command-line-parameter/
(Not allowed to post links until my account is verifyed)- Edited by Niccolas Monday, December 10, 2012 10:08 PM
-
Monday, December 10, 2012 10:34 PM
I actually solved it while writing my other post.
It works with C:\MoveOU.vbs and not %SCRIPTROOT%\MoveOU.vbs .....
Tested three deployments now just to be sure.Solution
I copied the script to V:\MININT\Scripts by adding MoveOU.vbs to LTICopyScripts.wsf.
Then in the task sequence I wrote cscript.exe %SCRIPTROOT%\MoveOU.vbs "OU=Deployment,DC=testdeploy,DC=com"
Run as BuildAccount.It looks like %SCRIPTROOT% is C:\MININT\Scripts when the Run command line task is executed, and not DeploymentShare\Scripts.
- Edited by Niccolas Monday, December 10, 2012 10:40 PM
-
Thursday, December 13, 2012 9:44 AM
If you just put your script into your deploymentshare\scripts folder then MDT should find it and copy it down to the client.
From then on, the command cscript %SCRIPTROOT%\MyScript.vbs "OU=Deployment,DC=testdeploy,DC=com" should run your script for you
There's no need to edit the zticopyscripts.wsf.
Blog: http://scriptimus.wordpress.com

