Move Computer to Staging OU script question

Feb 21, 2013 at 4:47 PM
This is more a script question rather than the actual web service itself but I will throw it out there. So I am using the three scripts provided to move computers to a Staging OU and then to the OU I have assigned the computer at the end of my task sequence. So far it works perfect with one exception. I have the Z_MoveComputer_StagingOU.wsf script running as the first step in Preinstall. If computers are in AD it moves them perfect. If they are not in AD it errors out. No problem there as I just have it continue on error and it swaps the values of the OU. When the task sequence completes in final summary it pops up with the warning "move to staging ou was not successful rc=1". No worries I know that it worked. The question I have is there a way to modify the script so that the warning will not appear? Maybe a simple line that allows a return code 1? I am awful with scripting so I am not sure how to change it up. I have tried adding 1 to success codes on the task sequence step but that does not work.
Mar 13, 2013 at 11:40 PM
Edited Mar 13, 2013 at 11:41 PM
Use the executewebservice script and check for computerexistance, save to a property then make that a condition for that action to run:
Create a run command line task before the movecomputer task:
cscript.exe %ScriptRoot%\ZTI_ExecuteWebservice.wsf /wsSection:DoesComputerExist /wsProperty:PCExists /wsResultName:boolean
Then on the "MoveComputer" task right after it set the condition to "if all conditions are true" and "Task sequence variable PCExists equals true"

Dont forget to create the custom property PCExists.

In Custom Properties ini file:
Mar 14, 2013 at 4:34 PM
Edited Mar 14, 2013 at 5:55 PM
Thank you for the tip. It worked with a little tweaking. Instead of HostName I needed to change it to OSDComputerName. Now the issue presented is that the "MoveComputer" script that is also used to swap the values of the OU's is bypassed. So the OU values don't change so that a computer joins into a staging OU. So to over come that I added the "SwapOU" script under the "MoveComputer" script and just reversed the logic.

The "SwapOU" task is set to the condition "if all conditions are true" and "Task sequence variable PCExists equals False"

So the end result is that if a computer is not in AD the "MoveComputer" is bypassed and the "SwapOU" script is run instead. If the computer is already in AD then the "MoveComputer" script is run and the the OU values are changed and the "SwapOU" script is bypassed.

Solved my problem. I really appreciate the help.

Thank you
May 22, 2013 at 12:30 PM

I am having the same issue that you were having. However, I am a little confused on how you changed the conditions on the "MoveComputer" and "SwapOU" scripts. Would you mind sharing the changes you made? Perhaps a sample copy of the code.

May 22, 2013 at 2:13 PM
I am in a meeting for the next 4 hours but when I am done I will give you exactly what I did with screenshots and a walk through.
May 22, 2013 at 4:56 PM
Thank you. I appreciate you taking time out.
May 28, 2013 at 2:45 PM
I found a solution that works for me using only the ZTI_ExecuteWebservice.wsf script.

First, I call the script during the Preinstall phase using with a continue with error checked:
cscript.exe %ScriptRoot%\ZTI_ExecuteWebservice.wsf /wsSection:MoveToStage
Second, I call the script during the State Restore phase using:
cscript.exe %ScriptRoot%\ZTI_ExecuteWebservice.wsf /wsSection:MoveToFinalOU
Third, in the CustomSettings.ini I added the following:

FinalOU="My final OU path"


The results: if the computer already exists in AD, it is moved to the specified OU, im my case one specifically for imaging. If the account the script may error but the process continues anyway. Lastly, as one of the final steps the computer account is moved from the staging ou into a pre-specified ou. This way the final reboot allows normal policy to be applied.