xPSDesiredStateConfiguration
xPSDesiredStateConfiguration copied to clipboard
Bug in xPackage resource: Uninstalling software does not work for .exe and .msi
Details of the scenario you tried and the problem that is occurring
Uninstalling a .exe or .msi hangs forever as the argument handling is incorrect. The Set function calls 'msiexec.exe' and adds the installation arguments to the call. As this does not work, the process hangs waiting for input.
Verbose logs showing the problem
VERBOSE: [INF001]: LCM: [ Start Set ] [[xPackage]WinRAR 5.91 (64-bit)]
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] The path extension was '.exe'.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] Ensure is 'Absent'.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] product 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinRAR archiver' found.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] product as boolean is 'True'.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] The package 'WinRAR 5.91 (64-bit)' is installed.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] The path extension was '.exe'.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] Package configuration starting.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] Checking file 'C:\dsc\WinRAR 5.91 (64-bit).exe' for expected 'SHA256' hash value of '892F7FDFDAF9FCEC6C035C8C65B280E18B7797620F4375699A2D4D41F60F794C'.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] The binary is an EXE.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] Starting 'C:\Windows\system32\msiexec.exe' with '/x "WinRAR archiver" /quiet /norestart /S'.
VERBOSE: [INF001]: [[xPackage]WinRAR 5.91 (64-bit)] Starting process 'C:\Windows\system32\msiexec.exe' with arguments '/x "WinRAR archiver" /quiet /norestart /S'.
Suggested solution to the issue
Use the 'UninstallString' available in the registry instead of calling 'msiexec.exe'.
The DSC configuration that is used to reproduce the issue (as detailed as possible)
configuration PackageTest {
Import-DscResource -ModuleName xPSDesiredStateConfiguration
Node localhost
{
foreach ($package in $packages)
{
xPackage $package.Name
{
Ensure = 'Absent'
Name = $package.Name
Path = $package.Path
ProductId = ''
Arguments = $package.Arguments
IgnoreReboot = $true
FileHash = $package.FileHash
}
}
}
}
$packages = @(
@{
Name = 'WinRAR 5.91 (64-bit)'
Path = 'C:\dsc\WinRAR 5.91 (64-bit).exe'
Arguments = '/S'
FileHash = '892F7FDFDAF9FCEC6C035C8C65B280E18B7797620F4375699A2D4D41F60F794C'
}
)
Remove-Item -Path C:\DSC\*.mof -Force
PackageTest -OutputPath C:\DSC
Start-DscConfiguration -Path C:\DSC -Wait -Verbose -Force
The operating system the target node is running
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Version and build of PowerShell the target node is running
Name Value
---- -----
PSVersion 5.1.17763.1432
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1432
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Version of the DSC module that was used
9.1.0