[CmdletBinding()] Param() process { $myCurrentPath = $PSScriptRoot; Write-Verbose "Uninstalling the Module from $myCurrentPath"; $parentPath = (Split-Path $myCurrentPath); $systemModulePath = "C:\Program Files\WindowsPowerShell\Modules\"; $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; } }