Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

- xPackage
- Uninstalling software (Ensure = Absent) did not work due to improper handling of arguments. This fixes #704.
- Fixed a bug not allowing using the file hash of an installer [Issue #702](https://github.com/dsccommunity/xPSDesiredStateConfiguration/issues/702).

### Fixed
Expand Down
36 changes: 21 additions & 15 deletions source/DSCResources/DSC_xPackageResource/DSC_xPackageResource.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -539,30 +539,36 @@ function Set-TargetResource
else
{
# Absent case
$startInfo.FileName = "$env:winDir\system32\msiexec.exe"

# We may have used the Name earlier, now we need the actual ID
if ($null -eq $productEntry -or $null -eq $productEntry.Name)
try
{
$id = $Path
$startInfo.FileName = $productEntry.GetValue('UninstallString')

if ($Arguments)
{
# Append the specified arguments with a space (#195)
$startInfo.Arguments = " $Arguments"
}
}
else
catch
{
$id = Split-Path -Path $productEntry.Name -Leaf
}
# We may have used the Name earlier, now we need the actual ID
if ($null -eq $productEntry -or $null -eq $productEntry.Name)
{
$id = $Path
}
else
{
$id = Split-Path -Path $productEntry.Name -Leaf
}

$startInfo.Arguments = "/x `"$id`" /quiet /norestart"
$startInfo.FileName = "$env:winDir\system32\msiexec.exe"
$startInfo.Arguments = "/x `"$id`" /quiet /norestart"
}

if ($LogPath)
{
$startInfo.Arguments += ' /log "{0}"' -f $LogPath
}

if ($Arguments)
{
# Append the specified arguments with a space (#195)
$startInfo.Arguments += ' {0}' -f $Arguments
}
}
}

Expand Down