Hi Everyone,
I want to accept users input for the list of templates available in vmware server, so that i can then create a vm from that template.
here is the code that i have written. Thanks in Advance to everyone.
###########################
Connect-VIServer -Server 10.209.130.40
$template = Get-Template # list of all vm templates available
Write-Host
$len = $template.length ## number of templates available.
Write-Host Available Templates
for($i=0; $i -le $len - 1; $i++){Write-Host; Write-Host $i $template[$i]} ## showing user the list of templates they can use
##i am facing problem in below function. i want all above templates, to show to users, then users gives one number and then with New-VM command i can create the vm with that template.
function Get-Site
{
$site=Read-Host "Choose a site code"
Switch ($site)
{
'1' {Write-Host You input server $Chosensite;}
}
return $Chosensite
}
& Get-Site