Clone VM and execute script

  • 4 March 2022
  • 6 replies
  • 303 views

Badge

Hi,

I want to clone a VM in a isolated network.

The isolated network is the same as Production (same IP / same name). There is no communication between production network and isolated network.

After the VM is cloned, i start it and i need to execute a script for ajustements.

Is it a way by API (prism) or anything else to execute locally a script?

Thanks for your help,

Matt


This topic has been closed for comments

6 replies

Userlevel 2
Badge +3

Hello MattieuC,

Do you need this script everytime VM boots up ?

Badge

Hi,

I want to automaticaly clone a Domain Controler to an isolated network.

And i need to execute a script just one time at first boot for seize FSMO role.

Here an example of a powershell script that i need to execute just one time at first boot :

#Define variable for CDM EXEC
$Roles = "role"
$conn = "connections"
$conn2 = '"connect to server VMDC01"'
$exit = "q"
$RID = '"seize RID master"'
$schema = '"seize schema master"'
$nameMaster = '"seize naming master"'
$PDC = '"seize pdc"'
$infraMaster = '"seize infrastructure master"'
$all = $Roles + " " + $conn + " " + $conn2 + " " + $exit + " " + $RID + " " + $schema + " " + $nameMaster + " " + $PDC + " " + $infraMaster + " " + $exit + " " + $exit

#Launch CMD to transfert FSMO RID and SCHEME ROLES
Start-Process "ntdsutil" $all

 

Matt

Userlevel 2
Badge +3

Hello Matt,

It is not a recommended to clone a Domain Controller. However, I would recommend you to reach out to Microsoft for details guidance on above scenario.

Let me know, if I can assist more on Nutanix aspect.

Rohan

Badge

Hi,

I know that.

It is not for production but test environement !

We already do it manually and we want to do it automaticaly by Ansible.

Matt

Userlevel 2
Badge +3

Hello Matthieu,

Thanks for the response. Based on the details shared, this is an application layer or OS Level action. I would recommend you to reach out to Microsoft for details guidance on above scenario.

Based on my past experience, the simplest way of running a program at startup on Windows is to place an executable file in the Startup folder. All the programs that are in this folder will be executed automatically when the computer opens. The location of this folder on Windows is following:

%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup

You can open this folder more easily by pressing WINDOWS KEY + R and then copying this text shell:startup.We can do this by creating a BAT (.bat) / VBS (.vbs) or Powershell (.ps1).

 

Rohan

Badge

Hi,

Your idea is too place a batch into %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup and if i do this i need to copied the script on the source VM before cloning it.

I don’t want to add or modify something on the source VM because it is a DC of our Production environnement.

I am giving up because :

i need to execute a powershell script at startup  without modify source VM

I need to execute the script to adapat the A.D. Domain with “Admins Domain” permission…

Matt