Hello everybody,
I have a big problem.
My script does not increment the rear IP parameters as follows: 10.170.229.10, 10.170.229.11, 10.170.229.12.
Indeed, in my loop, I set the variable "IP + +" to increment each time the last decimal my ip: 10170229.% 1
Here is my scrip:
param($Count,$Name,$Type,$Ip)
Connect-VIServer -Server 10..*.*.* -Protocol https -User admin -Password admin
2..$Count | Foreach {
New-vm -vmhost 007.london.england.eu -Name "$Name$_" -Template $Type -Datastore Data_base007 }
read-host "Press Enter"
2..$Count | Foreach {
Start-VM -VM "$Name$_"}
read-host "Press Enter"
2..$Count | Foreach {
$VM = Get-VM "$Name$_"
write-host "$Name$_"
$ESXHost = $VM | Get-VMHost
$secpasswd = ConvertTo-SecureString "formation" -AsPlainText -Force
$GuestCred = New-Object System.Management.Automation.PSCredential ("formation", $secpasswd)
Function Set-WinVMIP ($VM, $HC, $GC){
$Ip++
$ps1= "c:\ip.bat $Ip $VM"
Invoke-VMScript -VM $VM -HostCredential $HC -GuestCredential $GC -ScriptType bat -ScriptText $ps1
}
Set-WinVMIP $VM $HostCred $GuestCred
}
would you have a solution to this problem?
Thank you.