TechTutorials - Free Computer Tutorials  







VBScript - Save State and Commit Undo Disks 
 


Added: 12/05/2005, Hits: 3,730, Rating: 0, Comments: 0, Votes: 0
Add To Favorites | Comment on this article
I wrote this vbscript to Shutdown a known virtual server. It uses the GuestOS function to shutdown the operating system cleanly. (VM Additions must be installed for this to work).

It uses the VMTask output to ensure it waits until the server is shutdown before carrying out the next line of code. The -1 value indicates an unlimited time (use with extreme caution!). It then discards the Undo disks - I plan to run this on my Virtual network every night to clear any configurations and testings any co-workers have made through the day - so each day starts with a clean, trusted image.

Code :

set virtualserver = createobject("virtualserver.application")
set curvm = virtualserver.findvirtualmachine("My Server")
set CurOSint = curvm.GuestOS
set vmtask1 = CurOSint.shutdown
vmtask1.WaitForCompletion(-1)

curvm.DiscardUndoDisks


Although I need to discard undo disks on my virtual servers daily as I also run Active Directory, this would eventually upset replication and AD timestamps etc. Several hours after discarding undo disks in the evening I wanted to schedule a merge of the undo disks daily - so timestamps, replication and any other time / date related info can be added to the master disk. The script will save the servers state, wait for the VMTask to output the job has completed, and merge the Undo disk.

Code :

set virtualserver = createobject("virtualserver.application")
set curvm = virtualserver.findvirtualmachine("My Server")
set vmtask1 = curvm.save
vmtask1.WaitForCompletion(-1)
set vmtask2= curvm.mergeundodisks
vmtask2.WaitForCompletion(-1)





Comments (0)

Be the first to comment on this article


Related Items








7 Seconds Resources, Inc.




IT Showcase