Install-Module -Name VMware.PowerCLI
"https://www.powershellgallery.com/packages/VMware.PowerCLI/11.5.0.14912921" adresinde versiyonlar görülebilir.
Silmek için aşağıdaki komutlar uygulanır;
(Get-Module VMware.PowerCLI -ListAvailable).RequiredModules | Uninstall-Module -Force
Get-Module -ListAvailable | where {$_.Name -like "VMware.POWERCLI"} | Uninstall-Modulegg
Get-Module -ListAvailable | where {$_.Name -like "VMware.Vim*"} | Uninstall-Module -force
Versiyon bilgileri:
PowerShell Sürümü (PSVersion) 5.1.14393.3053
VSphere 6.7
PowerShell Modül Versiyonu 11.5.0.14912921
(Start --> Run --> PowerShell --> $PSversionTable)
Sertifika uyarısını atlamak için aşağıdaki komut uygulanır.
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore
$VIServer = "vcenter1"
$ESXiHost = "esxi1"
$sayi = 2
$SSD = "esxi1_LocalDatastore1_ssd"
$SAS = "esxi1_LocalDatastore2_sas"
$ESXiServerUserName = "root"
$ESXiServerUserPass = "..."
$VIServerUserName = "kullanici"
$VIServerUserPass = "..."
write $VIServer "sunucusuna bağlanılıyor...."
Connect-VIServer $VIServer -User $VIServerUserName -Password $VIServerUserPass -ErrorAction Ignore
Write "***********************************"
$TestCloneVms = get-vm | where {$_.Name -Like "_CLNPrfms*"} | Get-Unique
if ($TestCloneVms -ne $null) {
write "null değil"
foreach ($DeleteTestCloneVm in $TestCloneVms) {
if ($DeleteTestCloneVm.PowerState -eq "PoweredOn") {
write "stop vm"
stop-vm -VM $DeleteTestCloneVm.name -Confirm:$false
}
Remove-VM -VM $DeleteTestCloneVm.name -Server $VIServer -DeletePermanently -Confirm:$false
echo $DeleteTestCloneVm
}
}
else {
write "Silinecek Clone test VM yok"
}
$Baslangic = (Get-Date)
for ($sayac = 1; $sayac -le $sayi; $sayac++)
{
echo $sayac
#Yeni Klon VM - Vm to Clone
#new-vm -Name _CLNPrfms$Sayac -VM OStestWin10 -VMHost esxi1 -Datastore $SSD
#Sablondan VM - from Template
new-vm -Name _CLNPrfms$Sayac -Template OSTest3.Template -VMHost esxi1 -Datastore $SAS
}
$Bitis = (Get-Date)
"Elapsed Time: $(($Bitis-$Baslangic).totalminutes) makine Clon süresi dakika"
"Elapsed Time: $(($Bitis-$Baslangic).totalseconds) makine Clon süresi saniye"
$PowerTestCloneVms = get-vm | where {$_.Name -Like "*_CLNPrfms*"} | Get-Unique
$BaslangicPowerOn = (get-date)
foreach ($PowerOnTestCloneVms in $PowerTestCloneVms) {
Start-VM $PowerOnTestCloneVms.Name
write $PowerOnTestCloneVms
}
$BitisPowerOn = (get-date)
"Elapsed Time: $($BitisPowerOn-$BaslangicPowerOn).totalminutes) Makine Power-On dakika"
"Elapsed Time: $($BitisPowerOn-$BaslangicPowerOn).totalseconds) Makine Power-On saniye"
$VIServer = "vcenter1"
$ESXiHost = "esxi1"
$sayi = 2
$SSD = "esxi1_LocalDatastore1_ssd"
$SAS = "esxi1_LocalDatastore2_sas"
$ESXiServerUserName = "root"
$ESXiServerUserPass = "..."
$VIServerUserName = "kullanici"
$VIServerUserPass = "..."
write $VIServer "sunucusuna bağlanılıyor...."
Connect-VIServer $VIServer -User $VIServerUserName -Password $VIServerUserPass -ErrorAction Ignore
Write "***********************************"
$TestCloneVms = get-vm | where {$_.Name -Like "_CLNPrfms*"} | Get-Unique
if ($TestCloneVms -ne $null) {
write "null değil"
foreach ($DeleteTestCloneVm in $TestCloneVms) {
if ($DeleteTestCloneVm.PowerState -eq "PoweredOn") {
write "stop vm"
stop-vm -VM $DeleteTestCloneVm.name -Confirm:$false
}
Remove-VM -VM $DeleteTestCloneVm.name -Server $VIServer -DeletePermanently -Confirm:$false
echo $DeleteTestCloneVm
}
}
else {
write "Silinecek Clone test VM yok"
}
$Baslangic = (Get-Date)
for ($sayac = 1; $sayac -le $sayi; $sayac++)
{
echo $sayac
#Yeni Klon VM - Vm to Clone
#new-vm -Name _CLNPrfms$Sayac -VM OStestWin10 -VMHost esxi1 -Datastore $SSD
#Sablondan VM - from Template
new-vm -Name _CLNPrfms$Sayac -Template OSTest3.Template -VMHost esxi1 -Datastore $SAS
}
$Bitis = (Get-Date)
"Elapsed Time: $(($Bitis-$Baslangic).totalminutes) makine Clon süresi dakika"
"Elapsed Time: $(($Bitis-$Baslangic).totalseconds) makine Clon süresi saniye"
$PowerTestCloneVms = get-vm | where {$_.Name -Like "*_CLNPrfms*"} | Get-Unique
$BaslangicPowerOn = (get-date)
foreach ($PowerOnTestCloneVms in $PowerTestCloneVms) {
Start-VM $PowerOnTestCloneVms.Name
write $PowerOnTestCloneVms
}
$BitisPowerOn = (get-date)
"Elapsed Time: $($BitisPowerOn-$BaslangicPowerOn).totalminutes) Makine Power-On dakika"
"Elapsed Time: $($BitisPowerOn-$BaslangicPowerOn).totalseconds) Makine Power-On saniye"