Fixed CheckedModuleInstalled function

Fixed response display if module is not installed.
This commit is contained in:
ackitsme committed 2026-08-05 09:13:00 -07:00
1 parent 37adc4f178
commit a3badc4f9e
1 file changed
+10 -10
+10 -10
View File
@@ -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