From c881d563ed35f34c81938ee15c0701a1f85c10b3 Mon Sep 17 00:00:00 2001 From: sitiom <56180050+sitiom@users.noreply.github.com> Date: Sun, 22 Nov 2020 08:32:21 +0800 Subject: [PATCH] Add PowerShell uninstall script --- Tips-and-Tricks.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Tips-and-Tricks.md b/Tips-and-Tricks.md index 61d470e..a046622 100644 --- a/Tips-and-Tricks.md +++ b/Tips-and-Tricks.md @@ -186,3 +186,17 @@ for section in conf: print("Removing ", realpath) os.unlink(realpath) ``` + +Here's an equivalent script for PowerShell ([source](https://github.com/anishathalye/dotfiles_template/pull/19#issuecomment-729518540), [powershell-yaml](https://github.com/cloudbase/powershell-yaml) required) + +```ps +$CONFIG = "install.conf.yaml" + +$confObj = ConvertFrom-Yaml ([string](Get-Content $CONFIG -Raw)) +foreach ($target in ($confObj | Where-Object Keys -eq link).Values.Keys) { + if ((Get-Item $target -Force -ErrorAction SilentlyContinue).LinkType -eq "SymbolicLink") { + Write-Host "Removing $target" -ForegroundColor Red + Remove-Item $target + } +} +``` \ No newline at end of file