Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 179681

Problem script virtual machines creation

$
0
0

Hello everybody,

 

I come to you for have of your lights about my problem

 

My script creates 10 virtual machines and configure them (name and IP address).

my problem is my script only create that 3 VMs and stops there, you had an idea?

 

param($Count,$Name,$Type,$Salle,$Ip) 
$Count= $count-1
Connect-VIServer -Server 10.*.*.* -Protocol https -User admin -Password pwd 
New-Folder -Name $Salle -Location Salle 

0..$Count | Foreach {
  New-vm -vmhost Server01.london.server.fr -Name "$Name$_" -Template $Type -Location $Salle -Datastore IA015_LN_30   write-host $count
 Start-VM -VM "$Name$_" 
 write-host "$Name$_"
 $VM = Get-VM "$Name$_" 
 write-host $VM
while ($VM.PowerState -ne "PoweredOn"){     sleep 5    
 $VM = Get-VM $VM 
 }
write-host "wait"
sleep 60
write-host "$Name$_"
$ESXHost = $VM | Get-VMHost
$secpasswd = ConvertTo-SecureString "format" -AsPlainText -Force
$GuestCred = New-Object System.Management.Automation.PSCredential ("Password", $secpasswd)
Function Set-WinVMIP ($VM, $HC, $GC, $Ip){  
$ps1= "C:\WINDOWS\system32\ip.bat $Ip $VM"
#$ps1= "c:\ip.bat $Ip $VM"
Invoke-VMScript -VM $VM -HostCredential $HC -GuestCredential $GC -ScriptType bat -ScriptText $ps1 
}
Set-WinVMIP $VM $HostCred $GuestCred $Ip
$Ip++
}

Thanks everybody,


Viewing all articles
Browse latest Browse all 179681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>