Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AsBuiltReport.VMware.Horizon.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AsBuiltReport.VMware.Horizon.psm1'

# Version number of this module.
ModuleVersion = '1.1.5'
ModuleVersion = '1.1.5.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.5] - 2025-1-21
## [1.1.5.1] - 2025-03-13

### Fixed
- Fix `Get-RequiredModule` script function to properly check for installed VMware PowerCLI versions ([Fix #36](https://github.com/AsBuiltReport/AsBuiltReport.VMware.Horizon/issues/36))

## [1.1.5] - 2025-01-21

### Added

Expand Down
46 changes: 33 additions & 13 deletions Src/Private/Get-RequiredModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,53 @@ function Get-RequiredModule {
Function to check if the required version of VMware PowerCLI is installed
.DESCRIPTION
Function to check if the required version of VMware PowerCLI is installed
.NOTES
Version: 0.1.1
Author: Tim Carman
Twitter: @tpcarman
Github: tpcarman
.PARAMETER Name
The name of the required PowerShell module
.PARAMETER Version
The version of the required PowerShell module
#>
[CmdletBinding()]

Param
(
Param (
[CmdletBinding()]
[Parameter(Mandatory = $true, ValueFromPipeline = $false)]
[ValidateNotNullOrEmpty()]
[String] $Name,
[String]$Name,

[CmdletBinding()]
[Parameter(Mandatory = $true, ValueFromPipeline = $false)]
[ValidateNotNullOrEmpty()]
[String] $Version
[String]$Version
)

begin {}

process {
# Check if the required version of VMware PowerCLI is installed
$RequiredModule = Get-Module -ListAvailable -Name $Name | Sort-Object -Property Version -Descending | Select-Object -First 1
$ModuleVersion = "$($RequiredModule.Version.Major)" + "." + "$($RequiredModule.Version.Minor)"
if ($ModuleVersion -eq ".") {
throw "VMware PowerCLI $Version or higher is required to run the VMware Horizon As Built Report. Run 'Install-Module -Name $Name -MinimumVersion $Version' to install the required modules."
# Convert required version to a [Version] object
$RequiredVersion = [Version]$Version

# Find the latest installed version of the module
$InstalledModule = Get-Module -ListAvailable -Name $Name |
Sort-Object -Property Version -Descending |
Select-Object -First 1

if ($null -eq $InstalledModule) {
throw "VMware PowerCLI $Version or higher is required. Run 'Install-Module -Name $Name -MinimumVersion $Version -Force' to install the required modules."
}
if ($ModuleVersion -lt $Version) {
throw "VMware PowerCLI $Version or higher is required to run the VMware Horizon As Built Report. Run 'Update-Module -Name $Name -MinimumVersion $Version' to update the required modules."

# Convert installed version to a [Version] object
$InstalledVersion = [Version]$InstalledModule.Version

Write-PScriboMessage -Plugin "Module" -IsWarning "$($InstalledModule.Name) $InstalledVersion is currently installed."

if ($InstalledVersion -lt $RequiredVersion) {
throw "VMware PowerCLI $Version or higher is required. Run 'Update-Module -Name $Name -MinimumVersion $Version -Force' to update the required modules."
}
}

end {}
}
}
2 changes: 1 addition & 1 deletion Src/Public/Invoke-ASBuiltReport.VMware.Horizon.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.DESCRIPTION
Documents the configuration of VMware Horizon in Word/HTML/XML/Text formats using PScribo.
.NOTES
Version: 1.1.5
Version: 1.1.5.1
Author: Chris Hildebrandt, Karl Newick
Twitter: @childebrandt42, @karlnewick
Editor: Jonathan Colon, @jcolonfzenpr
Expand Down