Open garyneville opened 5 months ago
I just want to add my own fix for this; I'm not an expert, and i'm sure it's not up to scratch as a proper fix, but it works for me.
if (Get-Module -Name DISM -ListAvailable) {
Import-Module -Name DISM
}
else {
# Correctly resolve the path to the Windows Kits directory, including handling the wildcard for version.
$baseAdkPath = "${env:ProgramFiles(x86)}\Windows Kits"
$adkVersionPaths = Get-ChildItem -Path $baseAdkPath -Directory | Where-Object { $_.Name -match '^\d+' } | Select-Object -ExpandProperty FullName
$moduleImported = $false
foreach ($versionPath in $adkVersionPaths) {
$adkDismPath = "$versionPath\Assessment and Deployment Kit\Deployment Tools\amd64\DISM"
$dismModulePath = Join-Path -Path $adkDismPath -ChildPath "DISM.psd1"
if (Test-Path $dismModulePath) {
Import-Module -Name $dismModulePath -ErrorAction SilentlyContinue
if ($?) {
$moduleImported = $true
break
}
}
}
if (-not $moduleImported) {
Fail-Json $result "The DISM PS module needs to be installed, this can be done through the windows-adk chocolately package"
}
}
SUMMARY
Getting the message "The DISM PS module needs to be installed, this can be done through the windows-adk chocolately package" even when the module has been installed - using Chocolatey.
ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
Other info - the suggested version of windows-adk is no longer available on Chocolatey (
So deleted the 'version' line and let it install the latest version.
This appears to be the problematic part of the module:
The path certainly does exist.
EXPECTED RESULTS
Expect to apply hotfix to my Windows Server 2008r2 server.
ACTUAL RESULTS
"The DISM PS module needs to be installed, this can be done through the windows-adk chocolately package"