0

I want to create a prompt box window to take a user input so that it makes the same numbers of VM as user inputs.

$clustername = Get-Cluster -Name 'BGC_CLUSTER'
$n=Read-Host -Prompt 'How many VMs you want to create'

for($i=1; $i -le $n; $i++)
{
    $name=Read-Host -Prompt 'Input your server  name'
    New-VM -Name  $name -ResourcePool $clustername -Datastore 'VV_FC10K_RAID5_BGCMW21' -DiskGB 20 -MemoryGB 2 -NumCpu 2 
    New-CDDrive -VM "$name" -IsoPath "[VV_FC10K_RAID5_BGCMW20]rhel-server-6.9-update-7-x86_64-dvd.iso" -StartConnected
    Write-Host "VM has been Created"
}

Write-Host "All VM's have been created"
2
  • 3
    And what exactly is your problem? Commented Jun 29, 2018 at 6:46
  • 6
    You want a GUI box? Try one of the thousand blogs about powershell GUI or use Sapien PowerShell Studio, Visual Studio, Admin Script Editor... You looking for someone to give you the code while you sip coffee, thats not how this site works. Commented Jun 29, 2018 at 7:08

1 Answer 1

0

Replace $n with below variable,You will get prompt box to enter number of VMs you want to create, $vms variable will store numbers VMs you wanted to create.

[int]$vms = [Microsoft.VisualBasic.Interaction]::InputBox("Enter number of VMs you want to create", "VMs")
Sign up to request clarification or add additional context in comments.

1 Comment

Looks like you have to do this before this answer works: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic")

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.