I’ve edited “DTS (v0.3)” so it can generate “.csv” and accept input from “.csv” file as well.
Feel free to send your comment and idea and if you find any bug/problem in this script please let me know, I hope this version can do better work and be useful.
[wpdm_file id=8]
#####################################################
function Header {
CLS
Write-Host "Name:`tDeploy Template Script (v0.4)"
}
#####################################################
<h1>Adding PSSnapin</h1>
$pssnap = Get-PSSnapin | Sort-Object Name
$APS = "No"
$PSIndex = 1
1..$pssnap.Count | foreach {
if ($pssnap[$PSIndex].Name -like "vmware.vimautomation.core") {
$APS = "Yes"
}
$PSIndex++
}
if ($APS -eq "No") {
Write-Host "Adding required PowerShell Snapin"
Add-PSSnapin VMware.VimAutomation.Core
}
<h1>Enabling multiple connection</h1>
$PCC = get-PowerCLIConfiguration
if ($test.DefaultVIServerMode -eq "single") {
Write-Host "Changing <code>&quot;Default VI Server Mode</code>""
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple
}
<h1>vCenter Server Connection</h1>
Header
Write-Host ""
$Target = Read-Host ("Which vCenter Do you want connect to")
if ($global:DefaultVIServer.Name -eq $Target) {
$CRMB = "Yes"
} else {
$VICSI = Get-VICredentialStoreItem | Sort-Object Host
$AI = "No"
foreach ($item in $VICSI) {
if ($Target -eq $item.Host) {
$AI = "Yes"
}
}
if ($AI -eq "No") {
$cred = Get-Credential
Write-Host "Connecting to $Target"
$NCR = Connect-VIServer -Server $Target -Credential $cred
} else {
Write-Host "Connecting to $Target"
$NCR = Connect-VIServer -Server $Target
}
if ($NCR.IsConnected -eq $true) {
$CRMB = "Yes"
} else {
$CRMB = "No"
}
}
<h1>Automated Mode functions and process</h1>
function AutomatedMode {
Header
Write-Host "<code>nFor automated mode you need to present</code>".csv<code>&quot; file in bellow format</code>nName,Template,VMHost,Datastore,ResourcePool,vApp,CustomizationProfile,StartState"
$AFEA = Read-Host ("<code>nDo you have csv file matching above format (Y/N) [default = N]&quot;)
Switch ($AFEA) {
&quot;y&quot; {
$CFP = Read-Host (&quot;Please give the full path of</code>".csv<code>&quot; file&quot;)
if ($CFP -notlike &quot;&quot;) {
Import-Csv -Path $CFP | foreach {
if ($($_.Name) -and $($_.Template) -and $($_.VMHost) -and $($_.Datastore) -notlike &quot;&quot;) {
if ($_.StartState -eq &quot;Yes&quot;) {
if ($_.CustomizationProfile -notlike &quot;&quot; -and $_.CustomizationProfile -notlike &quot;none&quot;) {
if ($($_.ResourcePool) -notlike &quot;&quot; -and $($_.ResourcePool) -notlike &quot;none&quot;) {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) -ResourcePool $($_.ResourcePool) | Start-VM
} elseif ($($_.vApp) -notlike &quot;&quot; -and $($_.vApp) -notlike &quot;none&quot;) {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) | Move-VM -Destination $($_.vApp) | Start-VM
} else {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) | Start-VM
}
} else {
if ($($_.ResourcePool) -notlike &quot;&quot; -and $($_.ResourcePool) -notlike &quot;none&quot;) {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -ResourcePool $($_.ResourcePool) | Start-VM
} elseif ($($_.vApp) -notlike &quot;&quot; -and $($_.vApp) -notlike &quot;none&quot;) {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) | Move-VM -Destination $($_.vApp) | Start-VM
} else {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) | Start-VM
}
}
} else {
if ($_.CustomizationProfile -notlike &quot;&quot; -and $_.CustomizationProfile -notlike &quot;none&quot;) {
if ($($_.ResourcePool) -notlike &quot;&quot; -and $($_.ResourcePool) -notlike &quot;none&quot;) {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) -ResourcePool $($_.ResourcePool)
} elseif ($($_.vApp) -notlike &quot;&quot; -and $($_.vApp) -notlike &quot;none&quot;) {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) | Move-VM -Destination $($_.vApp)
} else {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile)
}
} else {
if ($($_.ResourcePool) -notlike &quot;&quot; -and $($_.ResourcePool) -notlike &quot;none&quot;) {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -ResourcePool $($_.ResourcePool)
} elseif ($($_.vApp) -notlike &quot;&quot; -and $($_.vApp) -notlike &quot;none&quot;) {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) | Move-VM -Destination $($_.vApp)
} else {
New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore)
}
}
}
}
}
$TOS = Read-Host (&quot;Would you like to create other series (Y/N)&quot;)
if ($TOS -like &quot;y&quot;) {
MainBody{}
} else {
Write-Host &quot;</code>nThanks for using <code>&quot;Deploy Template Script (v0.4)</code>"<code>nSohrab Kasraeian Fard (@Kasraeian)</code>n"
Exit
}
} else {
Write-Host ("<code>nProvided information is not correct&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
$Answer = Read-Host (&quot;</code>nDo you want to try again (Y/N) [default = Y]")
Switch ($Answer) {
"n" {
Header
Write-Host ("<code>nAll process aborted by user!</code>n") -BackgroundColor Yellow -ForegroundColor DarkRed
Write-Host "<code>nThanks for using</code>"Deploy Template Script (v0.4)<code>&quot;</code>nSohrab Kasraeian Fard (@Kasraeian)<code>n&quot;
Exit
}
default {
AutomatedMode{}
}
}
}
}
default {
Header
$CNCFA = Read-Host (&quot;</code>n[M] Manually create new <code>&quot;.csv</code>" file<code>n[Other keys] Exit</code>nPlease select from above items [default = Exit]")
Switch ($CNCFA) {
"m" {
Header
Write-Host "<code>nPlease provide below information, items with * are required in order to create new series of VMs&quot;
$Name = Read-Host (&quot;Please enter naming patern*&quot;)
$Template = Read-Host (&quot;Please enter source template name*&quot;)
$VMHost = Read-Host (&quot;Please define target host*&quot;)
$Datastore = Read-Host (&quot;Please define target datastore*&quot;)
$ResourcePool = Read-Host (&quot;Please enter resource pool to place new VM(s)&quot;)
$vApp = Read-Host (&quot;Please enter vApp to place new VM(s)&quot;)
$OSCP = Read-Host (&quot;Please select OS customization specification&quot;)
$StartState = Read-Host (&quot;Please type</code>"Yes<code>&quot; if you want to power on your VMs after their creation or</code>"No<code>&quot; for manual process&quot;)
$Qty = Read-Host (&quot;How many VM(s) do you want to deploy&quot;)
$SCF = Read-Host (&quot;Please provide full address to save csv file&quot;)
if ($Qty -ge 1) {
if ($Name -and $Template -and $VMHost -and $Datastore -and $SCF -notlike &quot;&quot;) {
$i = 1
$FileContent = &quot;Name,Template,VMHost,Datastore,ResourcePool,vApp,CustomizationProfile,StartState&quot;
1..$Qty | foreach {
$NewContent = &quot;</code>n$Name$i,$Template,$VMHost,$Datastore,$ResourcePool,$vApp,$OSCP,$StartState"
$FileContent = $FileContent + $NewContent
$i++
}
Header
Write-Host "<code>nNew</code>".csv<code>&quot; file would be create containing bellow information on $SCF</code>n"
$FileContent
$WCFA = Read-Host ("<code>nDo you want to save these information (Y/N)&quot;)
Switch ($WCFA) {
&quot;y&quot; {
$FileContent | Out-File $SCF
}
&quot;n&quot; {
$RWPA = Read-Host (&quot;</code>n[N] Create new <code>&quot;.csv</code>" file<code>n[M] Main menu</code>n[Other keys] Exit<code>nPlease select from above items [default = Exit]&quot;)
Switch ($RWPA) {
&quot;n&quot; {
AutomatedMode{}
}
&quot;m&quot; {
MainBody{}
}
default {
Header
Write-Host (&quot;</code>nAll process aborted by user!<code>n&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Write-Host &quot;</code>nThanks for using <code>&quot;Deploy Template Script (v0.4)</code>"<code>nSohrab Kasraeian Fard (@Kasraeian)</code>n"
Exit
}
}
}
}
$Answer = Read-Host ("<code>n[E] Edit</code>".csv<code>&quot; file and back to main menu</code>n[M] Main menu<code>n[Other keys] Exit</code>nPlease select from above items [default = Exit]")
Switch ($Answer) {
"e" {
Invoke-Item $SCF
MainBody{}
}
"m" {
MainBody{}
}
default {
Header
Write-Host ("<code>nAll process aborted by user!</code>n") -BackgroundColor Yellow -ForegroundColor DarkRed
Write-Host "<code>nThanks for using</code>"Deploy Template Script (v0.4)<code>&quot;</code>nSohrab Kasraeian Fard (@Kasraeian)<code>n&quot;
Exit
}
}
} else {
Write-Host (&quot;</code>nAll required data is not provided<code>n&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
$Answer = Read-Host (&quot;</code>nDo you want to try again (Y/N) [default = Y]")
Switch ($Answer) {
"n" {
Header
Write-Host ("<code>nAll process aborted by user!</code>n") -BackgroundColor Yellow -ForegroundColor DarkRed
Write-Host "<code>nThanks for using</code>"Deploy Template Script (v0.4)<code>&quot;</code>nSohrab Kasraeian Fard (@Kasraeian)<code>n&quot;
Exit
}
default {
AutomatedMode{}
}
}
}
} else {
Write-Host (&quot;You have provided wrong information, number of VM(s) to be deploy should more than 0&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
$Answer = Read-Host (&quot;</code>nDo you want to try again (Y/N) [default = Y]")
Switch ($Answer) {
"n" {
Header
Write-Host ("<code>nAll process aborted by user!</code>n") -BackgroundColor Yellow -ForegroundColor DarkRed
Write-Host "<code>nThanks for using</code>"Deploy Template Script (v0.4)<code>&quot;</code>nSohrab Kasraeian Fard (@Kasraeian)<code>n&quot;
Exit
}
default {
AutomatedMode{}
}
}
}
}
default {
Header
Write-Host (&quot;</code>nAll process aborted by user!<code>n&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Write-Host &quot;</code>nThanks for using <code>&quot;Deploy Template Script (v0.4)</code>"<code>nSohrab Kasraeian Fard (@Kasraeian)</code>n"
Exit
}
}
}
}
}
<h1>Interactive Mode functions and process</h1>
function InteractiveMode {
# Template Selection
Header
Write-Host ""
$Templates = Get-Template | Select Name | Sort-Object Name
if ($Templates.count -ge 2) {
$i = 1
$Templates | %{Write-Host $i":" $<em>.Name; $i++}
$SIndex = Read-Host "Enter a number ( 1 -" $Templates.Count ")"
$STemplate = $Templates[$SIndex - 1].Name
} elseif ($Templates.Name -notlike "") {
$i = 1
$Templates | %{Write-Host $i":" $</em>.Name; $i++}
$TSMC = Read-Host ("You only have one template, do you want to use it (Y/N) [default = Y]")
Switch ($TSMC) {
"n" {
Write-Host ("<code>nAll process aborted by user!</code>n") -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
default {
$STemplate = $Templates.Name
}
}
} else {
Write-Host "No template found, please check vCenter server and try again.`n" -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
<pre><code># Customization Profile Selection
Header
Write-Host &quot;&quot;
$OSCPs = Get-OSCustomizationSpec | Select Name | Sort-Object
if ($OSCPs.count -ge 2) {
$j = 1
$OSCPs | %{Write-Host $j&quot;:&quot; $_.Name; $j++}
Write-Host $j&quot;: None&quot;
$OSCPRC = $OSCPs.count + 1
$OSIndex = Read-Host &quot;Enter a number ( 1 -&quot; $OSCPRC &quot;)&quot;
$SOSCP = $OSCPs[$OSIndex - 1].Name
if ($OSIndex -eq $j) { $SOSCP = &quot;None&quot; }
} elseif ($OSCPs.Name -notlike &quot;&quot;) {
$j = 1
$OSCPs | %{Write-Host $j&quot;:&quot; $_.Name; $j++}
Write-Host $j&quot;: None&quot;
$OSIndex = Read-Host &quot;Enter a number ( 1 - 2 )&quot;
Switch ($OSIndex) {
1 { $SOSCP = $OSCPs.Name }
2 { $SOSCP = &quot;None&quot; }
}
} else {
Write-Host (&quot;Currently, you don't have any customization profile available.&quot;)
$CPSMC = Read-Host (&quot;[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]&quot;)
Switch ($CPSMC) {
&quot;a&quot; {
Write-Host (&quot;`nAll process aborted by user!`n&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
default {
$SOSCP = &quot;None&quot;
}
}
}
# Host Selection
Header
Write-Host &quot;&quot;
$VMHosts = Get-VMHost | Select Name | Sort-Object
if ($VMHosts.count -ge 2) {
$x = 1
$VMHosts | %{Write-Host $x&quot;:&quot; $_.Name; $x++}
$VMHIndex = Read-Host &quot;Enter a number ( 1 -&quot; $VMHosts.Count &quot;)&quot;
$SVMHost = $VMHosts[$VMHIndex - 1].Name
} elseif ($VMHosts.Name -notlike &quot;&quot;) {
$x = 1
$VMHosts | %{Write-Host $x&quot;:&quot; $_.Name; $x++}
$HSMC = Read-Host (&quot;You only have one host, do you want to use it (Y/N)&quot;)
if ($HSMC -like &quot;y&quot;) {
$SVMHost = $VMHosts.Name
} elseif ($HSMC -like &quot;n&quot;) {
Write-Host (&quot;`nAll process aborted by user!&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Read-Host (&quot;`nPress any key to exit&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
} else {
Write-Host &quot;No host found, please check vCenter server and try again.&quot;
Read-Host (&quot;`nPress any key to exit&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
# Datastore Selection
Header
Write-Host &quot;&quot;
$Datastores = Get-VMHost $SVMHost | Get-Datastore | Select Name,FreeSpaceGB,CapacityGB | Sort-Object CapacityGB
if ($Datastores.count -ge 2) {
$y = 1
$Datastores | %{Write-Host $y&quot;:&quot; $_.Name&quot;`t`tCapacity (GB):&quot; $_.CapacityGB&quot;`t`tFree Space (GB):&quot; $_.FreeSpaceGB; $y++}
$DSIndex = Read-Host &quot;Enter a number ( 1 -&quot; $Datastores.count &quot;)&quot;
$SDatastore = $Datastores[$DSIndex - 1].Name
} elseif ($Datastores.Name -notlike &quot;&quot;) {
$y = 1
$Datastores | %{Write-Host $y&quot;:&quot; $_.Name&quot;`t`tCapacity (GB):&quot; $_.CapacityGB&quot;`t`tFree Space (GB):&quot; $_.FreeSpaceGB; $y++}
$DSSMC = Read-Host (&quot;You only have one host, do you want to use it (Y/N) [default = Y]&quot;)
Switch ($DSSMC) {
&quot;n&quot; {
Write-Host (&quot;`nAll process aborted by user!&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
default {
$SDatastore = $Datastores.Name
}
}
} else {
Write-Host &quot;No datastore found, please check vCenter server and try again.&quot; -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
# Location Selection
Header
Write-Host &quot;&quot;
$LSA = Read-Host &quot;[R] Resource Pool`n[V] vApp`n[Other Keys] No Config (simple)`nPlease select location for placing new VM(s)&quot;
$SLocation = &quot;Root&quot;
Switch ($LSA) {
&quot;r&quot; {
Write-Host &quot;&quot;
$ARPs = Get-ResourcePool | Sort-Object Name
if ($ARPs.count -ge 2) {
$z = 1
$ARPs | %{Write-Host $z&quot;:&quot; $_.Name; $z++}
$RPIndex = Read-Host &quot;Enter a number ( 1 -&quot; $ARPs.count &quot;)&quot;
$SRP = $ARPs[$RPIndex - 1].Name
$SLocation = $ARPs[$RPIndex - 1]
} elseif ($ARPs.Name -notlike &quot;&quot;) {
$RPSMC = Read-Host (&quot;You only have one resource pool ($ARPs.Name), do you want to use it (Y/N) [default = Y]&quot;)
Switch ($RPSMC) {
&quot;n&quot; {
$SLocation = &quot;Root&quot;
}
default {
$SLocation = $ARPs.Name
}
}
} else {
Write-Host (&quot;Currently, you don't have any resource pool available.&quot;)
$RPSMC = Read-Host (&quot;[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]&quot;)
Switch ($RPSMC) {
&quot;a&quot; {
Write-Host (&quot;`nAll process aborted by user!`n&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
default {
$SLocation = &quot;Root&quot;
}
}
}
}
&quot;v&quot; {
Write-Host &quot;&quot;
$AVAs = Get-VApp | Sort-Object Name
if ($AVAs.count -ge 2) {
$k = 1
$AVAs | %{Write-Host $k&quot;:&quot; $_.Name;$k++}
$VAIndex = Read-Host &quot;Enter a number ( 1 -&quot; $AVAs.count &quot;)&quot;
$SVA = $AVAs[$VAIndex - 1].Name
$SLocation = $AVAs[$VAIndex - 1]
$SvApp = $AVAs[$VAIndex - 1]
} elseif ($AVAs.Name -notlike &quot;&quot;) {
$VASMC = Read-Host (&quot;You only have one resource pool ($AVAs.Name), do you want to use it (Y/N) [default = Y]&quot;)
Switch ($VASMC) {
&quot;n&quot; {
$SLocation = &quot;Root&quot;
$SvApp = &quot;none&quot;
}
default {
$SLocation = $AVAs.Name
$SvApp = $AVAs.Name
}
}
} else {
Write-Host (&quot;Currently, you don't have any vApp available.&quot;)
$VASMC = Read-Host (&quot;[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]&quot;)
Switch ($VASMC) {
&quot;a&quot; {
Write-Host (&quot;`nAll process aborted by user!`n&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Exit
}
default {
$SLocation = &quot;Root&quot;
$SvApp = &quot;none&quot;
}
}
}
}
default {
$SLocation = &quot;Root&quot;
}
}
# Name Selection
Header
Write-Host &quot;&quot;
$SName = Read-Host &quot;Please enter VMs Naming Patern&quot;
# Getting VM count
$NVMTD = Read-Host &quot;How many VMs do you want to deploy&quot;
# Getting confirmation and deploying
Header
Write-Host &quot;`nNew VM(s) would be created by bellow configuration
</code></pre>
Source Template: $STemplate
Target Host: $SVMHost
Target Datastore: $SDatastore
OS Customization Profile: $SOSCP
VM naming pattern: $SName
Number of VM(s): $NVMTD
Would place on: $SLocation"
<pre><code># Action Menu
$NVMDConf = Read-Host &quot;`n[C] Create VM(s)`n[S] Create and start VM(s)`n[R] Restart whole process`n[M] Main menu`n[Other Keys] Exit`nPlease select action from list [default = Exit]&quot;
switch ($NVMDConf) {
&quot;c&quot; {
Switch ($SOSCP) {
&quot;None&quot; { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore } }
default { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP } }
}
Switch ($SLocation) {
&quot;Root&quot; { break }
default { $NoOut = Get-VM | Where {$_.Name -like &quot;$SName*&quot;} | Move-VM -Destination $SLocation }
}
Write-Host &quot;`n----- Created VMs -----&quot; -NoNewline
Get-VM | Where {$_.Name -like &quot;$SName*&quot;} | Select Name,PowerState,NumCPU,MemoryMB | Format-Table -AutoSize
Write-Host &quot;You need to manually start your VMs.`n&quot; -BackgroundColor Yellow -ForegroundColor Blue
$TOS = Read-Host (&quot;Would you like to create other series (Y/N)&quot;)
if ($TOS -like &quot;y&quot;) {
MainBody{}
} else {
Write-Host &quot;`nThanks for using `&quot;Deploy Template Script (v0.4)`&quot;`nSohrab Kasraeian Fard (@Kasraeian)`n&quot;
Exit
}
}
&quot;s&quot; {
Switch ($SOSCP) {
&quot;None&quot; { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore | Start-VM } }
default { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP | Start-VM } }
}
Switch ($SLocation) {
&quot;Root&quot; { break }
default { $NoOut = Get-VM | Where {$_.Name -like &quot;$SName*&quot;} | Move-VM -Destination $SLocation }
}
Write-Host &quot;`n----- Created VMs -----&quot;
Get-VM | Where {$_.Name -like &quot;$SName*&quot;} | Select Name,PowerState,NumCPU,MemoryMB | Format-Table -AutoSize
$TOS = Read-Host (&quot;Would you like to create other series (Y/N)&quot;)
if ($TOS -like &quot;y&quot;) {
MainBody{}
} else {
Write-Host &quot;`nThanks for using `&quot;Deploy Template Script (v0.4)`&quot;`nSohrab Kasraeian Fard (@Kasraeian)`n&quot;
Exit
}
}
&quot;r&quot; {
InteractiveMode{}
}
&quot;m&quot; {
MainBody{}
}
default {
Header
Write-Host (&quot;`nAll process aborted by user!`n&quot;) -BackgroundColor Yellow -ForegroundColor DarkRed
Write-Host &quot;Thanks for using `&quot;Deploy Template Script (v0.4)`&quot;`nSohrab Kasraeian Fard (@Kasraeian)`n&quot;
Exit
}
}
</code></pre>
}
function MainBody {
if ($CRMB -eq "Yes") {
Header
$ModeSelection = Read-Host ("<code>n[A] Automated Mode (csv)</code>n[I] Interactive Mode<code>n[Other keys] Exit</code>nPlease select from above list [default = E]")
Switch ($ModeSelection) {
"i" {
Header
InteractiveMode{}
}
"a" {
Header
AutomatedMode{}
}
default {
Header
Write-Host ("<code>nAll process aborted by user!</code>n") -BackgroundColor Yellow -ForegroundColor DarkRed
Write-Host "<code>nThanks for using</code>"Deploy Template Script (v0.4)<code>&quot;</code>nSohrab Kasraeian Fard (@Kasraeian)`n"
Exit
}
}
} else {
Write-Host ("Error on connecting to vCenter Server") -BackgroundColor Yellow -ForegroundColor DarkRed
}
}
MainBody
<h3>EOF ###
