From a3badc4f9e1a3d9ed0fb32d970ec262c8f97d9cd Mon Sep 17 00:00:00 2001 From: Charlie Silverman Date: Wed, 5 Aug 2026 09:13:00 -0700 Subject: [PATCH] Fixed CheckedModuleInstalled function Fixed response display if module is not installed. --- vSphere Tools/CollectVMInventory.ps1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vSphere Tools/CollectVMInventory.ps1 b/vSphere Tools/CollectVMInventory.ps1 index da0dff7..3e1e6ad 100644 --- a/vSphere Tools/CollectVMInventory.ps1 +++ b/vSphere Tools/CollectVMInventory.ps1 @@ -8,8 +8,8 @@ param ( ) # Variables -$fileVersion = "1.3.3" -$fileDate = "2026-08-04" +$fileVersion = "1.3.5" +$fileDate = "2026-08-05" $scriptName = Split-Path -Path $PSCommandPath -Leaf # Display Script Banner @@ -26,7 +26,7 @@ function CheckModuleInstalled($moduleName, $command) { if (-not (Get-Module -ListAvailable -Name $moduleName)) { $response = "" while (($response -ne "yes") -and ($response -ne "no")) { - $response = (Read-Host "ImportExcel module not instaled. Install now? (yes/no)").ToLower() + $response = (Read-Host "$moduleName module not instaled. Install now? (yes/no)").ToLower() } if ($response -eq "no") { Write-Host "Operation Cancelled." -ForegroundColor Yellow @@ -44,13 +44,6 @@ function CheckModuleInstalled($moduleName, $command) { } } -# Check for ImportExcel and install if missing -CheckModuleInstalled -moduleName "VCF.PowerCLI" -command "connect-viserver" -CheckModuleInstalled -moduleName "ImportExcel" -command "import-excel" - -$moduleName = "ImportExcel" -Import-Module ImportExcel - if ($Help) { Write-Host Write-Host "Purpose: Generate a migration spreadsheet from vCenter VMs." @@ -76,6 +69,13 @@ if ($Help) { exit } +# Check for ImportExcel and install if missing +CheckModuleInstalled -moduleName "VCF.PowerCLI" -command "connect-viserver" +CheckModuleInstalled -moduleName "ImportExcel" -command "import-excel" + +$moduleName = "ImportExcel" +Import-Module ImportExcel + $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $quiet = Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false