Some articles are posted as Images, Please use Computers to go through them for best experience. For phone users, switch to Web Version

Difference in Template & Cloning


People often get confuse in Templates & Cloning Concept. Let's understand the concept using a Scenario - 

Consider today is 1st Jan 2022, and you have deployed a VM named "VM1", configured various settings, Install required basic applications, Patching etc. Now the management has asked you to create 10 more identical VM's ( meaning same configuration , Applications, Patching etc). It would take so much time if you create & configure VM one by one, also there might be good chances of human errors as well.

In order to overcome this, we have two Concepts "Templates" & "Cloning". Both these concept serve similar purpose and that is creating VM's from existing Setup/VM. This saves our time & reduces chances of human errors.

Since both serve same purpose, then why do we have two Concepts ? Why not only one ?

Answer to this is the way these are used & when they are used.

To understand Template, Suppose the VM that we created & configure on Jan1 "VM1" is converted to a state where it can't be powered on. Now that state will act as a template & we can use it to create  new VM's.
So if I have converted VM1 to a template & use it to create new VM's  then no matter when you create New VM's, all will contain consistent settings & configurations.

Cloning - Here you are creating a new VM from a Live VM. So if you create another VM from VM1 on Jan1 itself, then that would ideally contain all the same configuration & settings ( Considering you haven't made any changes to VM1), but let's assume you created another VM from VM1 after 2 months, then the New VM might contain some extra/different settings from other VM's cloned from VM1 & this is simply because of changes made on VM1 in two months.

In Short, Template ensures consistent state & settings on all new VM's deployed from it whereas Cloning ensures identical duplicate copy of an existing/master VM's.


Apart from this, there are few more differences in both these concept's - 

1. You can't create a Template of a VM when it's powered on. You need to Powered off the VM first, whereas in cloning you can create a New VM from a Live running VM.

2. If required any editing on the template, you first need to convert the template back to a VM, do the changes & then convert it back to the template. In Cloning, since the VM is live, you can do the changes on the Live VM & then cloned a new VM out of the existing /parent VM.

Note - Administrators needs to be careful while Cloning a VM because there are good chances of IP conflict when they powered on the cloned VM & this is primarily because you master VM is also online & having same IP configuration.
To avoid, Administrators first uncheck NIC for the Cloned VM, power it on, login via Console,  do the IP, hostname, SID changes & then enable NIC.
 

Powershell Script - Creating New AD Groups

#Author - Abhishek Bansal 

$grp = Get-Content ./Input.txt
foreach($row in $grp){
$row = $row.trim()

    try
    {
    New-ADGroup -Name $row -GroupScope Global -GroupCategory Security -Path "OU=Groups,OU=Production,DC=Mari,DC=com" -PassThru | Select Name,@{n=("Status");e={("Created under")}},DistinguishedName | Export-Csv ./Output.csv -Append -NoTypeInformation
    }

catch
    {
       $row | Select-Object -Property @{n=("Name");e={($row)}},@{n=("Status");e={("already exist under ")}},@{n="DistinguishedName";e={(Get-ADGroup -Identity $row | Select DistinguishedName)}} | Export-Csv ./Output.csv -Append -NoTypeInformation
        }

}



Read Me !!

1. I am using a relative path to take input & export the output. So please make sure you Create a folder with any name of your liking, then copy the above script & save it with .ps1 extension into the folder.

2. Once copied, also create a text file name Input.txt ( This will be used to take input into our Script & it should contain AD Group names which we need to create.



3. Once done, run the script. It will create the new AD Group under OU mentioned in the script.














Please note- Some Arguments are static in the Script, they will definitely vary in your workspace, so  edit them as per your structure.

Arguments required editing - Group Scope / Category [ If you want some other Scope & Category ], Path - [ OU  Location where you want to create the Groups]

4. Also, If a Group is already created, then this script will through an error & for that we have mentioned Catch block. This way you can see which all Groups are created & which are already present, where it is present etc.



















Finish