VMware Cloud Community
Cart3r
Contributor
Contributor
Jump to solution

VCD Guest Customization fail to complete before vmtools reboots Server

Hi All,

Looking for some help. I am attempting to run a powershell script at post customization. This script works fine if run standalone. The issue I can see from the logs is the vmware tools marks the script as complete once run the initiates a system reboot. This obviously stops my powershell from finishing. The script is copying files to the guest to then perform an install.

So my question is does anyone know how to either stop vmtools from initiating the reboot until my script is finished or how to to tell my script to stop the vmtools from starting the reboot. I still want the tools to finish, but not until my script is done.

I have tried adding various command to the script with no joy, i think this is because vmtools starts the power shell command then considers/marks it complete and moves on regardless of what is happening. This is for Windows 2008 R2 servers and im using VCD 5.1.

Any ideas would be appreciated.

Paul

Message was edited by: Cart3r This is the customization script under the properties for the VM @echo off if "%1%" == "precustomization" ( echo Do precustomization tasks ) else if "%1%" == "postcustomization" ( echo Do postcustomization tasks powershell.exe -ExecutionPolicy Unrestricted -file C:\vCD\install-local-agent.ps1 )

0 Kudos
1 Solution

Accepted Solutions
aneverov
VMware Employee
VMware Employee
Jump to solution

Hi Paul,

Based on the log it seems to me that you actually run VCD 1.5 (not 5.1). Could you tell me Version/Build date from Help > About? If that's the case and you can't find a way to execute your script synchronously or the timeout of 100 sec is not enough, I would recommend to run your stuff by scheduling a separate Windows Task to run after reboot (this is how we do it in VCD 5.1.x):

\\system32\\schtasks.exe /create /sc ONSTART /rl HIGHEST /np /z /v1 /ru SYSTEM /tr "command" /tn "My Task"

Just remember that you might need to delete it afterwards, since Windows often fails to do so, even though the arguments instruct to do it.

/Andrii

/* Please remember to mark answer as 'helpful' or 'correct' such that other users know it can be used and people focusing on ‘unanswered’ questions can skip it. */

View solution in original post

0 Kudos
9 Replies
aneverov
VMware Employee
VMware Employee
Jump to solution

Hi Paul,

Do you run your script in the pre- or post-customization part? The former is run at the beginning and we generally don't recommend to execute any long-running tasks inside it. The overall timeout for that phase is around 100 sec. The later one is executed from Windows Task after the last reboot, so it shouldn't be a problem. Could you post the logs you mentioned?

Thanks,

Andrii

/* Please remember to mark answer as 'helpful' or 'correct' such that other users know it can be used and people focusing on ‘unanswered’ questions can skip it. */
0 Kudos
Cart3r
Contributor
Contributor
Jump to solution

Hi Andrii,

       Thanks for the reply, yes it runs in the post customization. The log is attached, the first part of our script is to copy files using robocopy which you can see starts in the log. However, this does not complete, its only about half way through. Then the reboot starts.

Paul

0 Kudos
aneverov
VMware Employee
VMware Employee
Jump to solution

Hi Paul,

Based on the log it seems to me that you actually run VCD 1.5 (not 5.1). Could you tell me Version/Build date from Help > About? If that's the case and you can't find a way to execute your script synchronously or the timeout of 100 sec is not enough, I would recommend to run your stuff by scheduling a separate Windows Task to run after reboot (this is how we do it in VCD 5.1.x):

\\system32\\schtasks.exe /create /sc ONSTART /rl HIGHEST /np /z /v1 /ru SYSTEM /tr "command" /tn "My Task"

Just remember that you might need to delete it afterwards, since Windows often fails to do so, even though the arguments instruct to do it.

/Andrii

/* Please remember to mark answer as 'helpful' or 'correct' such that other users know it can be used and people focusing on ‘unanswered’ questions can skip it. */
0 Kudos
Cart3r
Contributor
Contributor
Jump to solution

Hi Andrii,

We are using VCD v5.1.1.868405, however we have used the schedule task as suggested and this has allowed use to execute the script. Also as you said the task did not delete on completion but this is minor issue. So thanks for the assistance.

I am surprised that you have a such a short time to work with to run post customization tasks, i thought i was doing something wrong with the script.

Thanks, for you help

Paul

0 Kudos
aneverov
VMware Employee
VMware Employee
Jump to solution

Hi Paul,

I'm glad it helped. Actually I must correct myself - I believe 100 sec timeout is only for Linux. For Windows it seems like it can actually run indefinitely. Anyway, in your case the PowerShell script seem to quit earlier than it finishes all the tasks. And we reboot once we see the script is finished.

However, I'm now wondering about another thing. You run VCD 5.1.1, but is it upgraded from 1.5? The reason I'm asking is that you may be hitting another issue and still using 1.5 customization code (because of cached package files).

/Andrii

/* Please remember to mark answer as 'helpful' or 'correct' such that other users know it can be used and people focusing on ‘unanswered’ questions can skip it. */
0 Kudos
Cart3r
Contributor
Contributor
Jump to solution

You are correct, we did upgrade from 1.5 to 5.1.

Can you point me at any documentation which will allow me to confirm the customization code and if out of date how to update. We are starting to use VCD heavily so if we have older code knocking around i would like it updated.

Thanks, Paul

0 Kudos
aneverov
VMware Employee
VMware Employee
Jump to solution

Hm, let me explain the problem.

Guest customization is always delivered to the guest OS in a form of package. There are 3 types of packages: unix_deployment_package.tar.gz (used for Linux OSes), windows_deployment_package_sidgen.cab (used by Vista+ and XP/2003 [only in case "Change SID" == false]) and windows_deployment_package_sysprep.cab (used by XP/2003 only in case "Change SID" == true). On the clean install you don't have any of them. Documentation has instructions on how to create the third one, because VCD can't generate one automatically. But it's only needed if you have XP/2003 OSes, otherwise VCD can work without it. The other two can and normally are generated by VCD automatically. Once they are generated, they are used as some sort of cache. In other words VCD will never try to regenerate them again. So, it's a problem when you upgrade - the bug is that VCD doesn't regenerate the packages and keeps using the old code.

The fix of deleting all those packages went into 5.1.2 (+ a warning that you need to regenerate windows_deployment_package_sysprep.cab [if you had one] manually).

So, you can try to:

- backup the old files

- move them somewhere else

- run customization of Linux and Vista+ VM to get those regenerated

If something goes wrong, you can always put back the old files and VCD will keep using them.

/Andrii

/* Please remember to mark answer as 'helpful' or 'correct' such that other users know it can be used and people focusing on ‘unanswered’ questions can skip it. */
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

What in the log is a marker that it was generated from 1.5 instead of 5.1?  If I wanted to check ours I am not sure how to determine that.  I don't see a version number of any sort in the logs.

0 Kudos
aneverov
VMware Employee
VMware Employee
Jump to solution

Regrettably we don't log version number. I just see that there is much less logging - this is how I know.

As I mentioned before, it's is safe to move out old packages and let VCD regenerated them. That's what fix in 5.1.2 does. Of course you would need to do it for every cell and you may face sysprep complications if you use XP/2003 OSes.

/Andrii

/* Please remember to mark answer as 'helpful' or 'correct' such that other users know it can be used and people focusing on ‘unanswered’ questions can skip it. */
0 Kudos