From 23e31242ef507580d8b781d3b0570beb95005fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sava=C5=9F=20KARTAL?= Date: Thu, 14 Sep 2017 16:03:00 +0300 Subject: [PATCH] Update EncryptedvMotion.psm1 Move Config object outside the loop, and adding progress bar. --- EncryptedvMotion.psm1 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/EncryptedvMotion.psm1 b/EncryptedvMotion.psm1 index 1c1e89b..f6cd8be 100644 --- a/EncryptedvMotion.psm1 +++ b/EncryptedvMotion.psm1 @@ -87,19 +87,23 @@ begin{ write-host "Working... Please be patient." -ForegroundColor Cyan } process{ + $config = new-object VMware.Vim.VirtualMachineConfigSpec + $config.MigrateEncryption = New-object VMware.Vim.VirtualMachineConfigSpecEncryptedVMotionModes + $config.MigrateEncryption = "$encryption" + + $vmCount = $VM.count + $i = 0 + foreach ($obj in $VM) { + Write-Progress -Activity "Configuring VM(s)..." -PercentComplete (($i++ / $vmCount) * 100) -CurrentOperation "VM : $obj configuring." -Status "Configuring VM $i of $VMCount." + $VMView = $obj | get-view - $config = new-object VMware.Vim.VirtualMachineConfigSpec - $config.MigrateEncryption = New-object VMware.Vim.VirtualMachineConfigSpecEncryptedVMotionModes - $config.MigrateEncryption = "$encryption" - $VMView.ReconfigVM($config) } } -end{ -$VM | select Name, @{name="vMotionEncryption";Expression={$_.extensiondata.config.MigrateEncryption}} } - +end{ + $VM | select Name, @{name="vMotionEncryption";Expression={$_.extensiondata.config.MigrateEncryption}} } }