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