ps/Modules/Alkami.Ops.Common/tools/chocolateyUninstall.ps1
2023-05-30 22:51:22 -07:00

26 lines
810 B
PowerShell

[CmdletBinding()]
Param()
process {
$myCurrentPath = $PSScriptRoot;
Write-Verbose "Uninstalling the Module from $myCurrentPath";
$parentPath = (Split-Path $myCurrentPath);
$systemModulePath = "C:\Program Files\WindowsPowerShell\Modules\";
$myModulePath = (Join-Path $parentPath "module");
$metadata = ([Xml](Get-Content (Join-Path $parentPath "*.nuspec"))).package.metadata;
$id = $metadata.id;
$version = $metadata.version -replace '-pre.+','';
$targetModulePath = (Join-Path $systemModulePath $id);
$targetModuleVersionPath = (Join-Path $targetModulePath $version);
if (Test-Path $targetModuleVersionPath) {
Write-Information "Removing module at [$targetModuleVersionPath]!!"
Remove-Item $targetModuleVersionPath -Recurse -Force;
}
}