Search

MachPanel Knowledgebase

HOW TO:Creating Scheduled Task for Windows OS Initialization and Modification

Mudesira Munir
MachPanel

Summary

This article provide a summary on how to Create Scheduled Task for OS Initialization and Modification via Config.bat .

Applies To
This article applies to MachPanel v5.1.12 and above
Steps to create a Scheduled Task
In order to set passwords of VM, we need to create a "Scheduled Task" in sealed image of guest OS:
  1. Open Task Scheduler.
  2. Click "create new task".
    • Name task as: Reset VM Admin Password (Do not remove or disable, required to reset VM from Host)
    • Set task to be run under System user (NT Authority\System).
    • Choose "Run whether user is logged on or not."
  1. Un-check “Do not store password”


3. Under Triggers set “At Start up” and Enabled.

4. There is a difference between creation of scheduled task for Gen1 and Gen2 type virtual Machines as explained below:

  • Scheduled Task for Gen1: For Gen1, Set Action to run Powershell.exe -executionpolicy bypass -command ". cd 'a:';  (Get-content 'A:\Config.bat') | Foreach-Object {$_ -replace 'Administrator', 'Administrador'} | Set-Content 'A:\Config.bat'; A:\Config.bat;"”.
  • Scheduled Task for Gen2: For Gen2, Set Action to run “Powershell.exe -executionpolicy bypass -command ". cd 'c:';  (Get-content 'C:\Config.bat') | Foreach-Object {$_ -replace 'Administrator', 'Administrador'} | Set-Content 'C:\Config.bat'; C:\Config.bat;"”.

It is noted that some languages have different Default User name, like for Spanish VMs it is not “Administrator” and it is “Administrador”.

For this, the action we have added in our sealed image schedule task contains argument where you need to replace “Administrador” to your default “UserName”.

  • Critical Note: In above command you have to replace ‘Administrador’ with username in your environment:
    • Example: if it is ‘Administrator’ for your environment, replace ‘Administrador’ with ‘Administrator
    • If it is ‘SuperAdmin’, replace ‘Administrador’ with ‘SuperAdmin’.​
  • Note 2: You do not need to have a Config.bat file on C:\ or A:\ drive, just refer to C:\Config.bat or A:\Config.bat for Gen2 and Gen1 respectively while scheduling a task as shown in above image. Control Panel will automatically create this file in its respective location during VM Provisioning Process.

5. Set Conditions as indicated below:

6. Set Settings as indicated below:

More Information

Please review KB SOP for preparation of Sealed Images for Hyper-V before adding sealed images.

http://kb.machsol.com/Downloads/Download/50314


Details
Type: HOW TO
Level: Intermediate
Last Modified: Last Month
Last Modified By: zohaib.shaikh
Rated 4 stars based on 2 votes.
Article has been viewed 12K times.
Options
Also In This Category
Tags