Created
November 29, 2017 05:53
-
-
Save kentork/9488a9bd0bdeb0384aaab2c1bedcf404 to your computer and use it in GitHub Desktop.
Path Backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Date | Add-Content ~/.path -Encoding utf8 | |
[environment]::getEnvironmentVariable("PATH", "User") | Add-Content ~/.path -Encoding utf8 | |
[environment]::getEnvironmentVariable("PATH", "Machine") | Add-Content ~/.path -Encoding utf8 | |
"`r`n" | Add-Content ~/.path -Encoding utf8 | |
$saving = 20 | |
$maxline = 5 * $saving | |
$contents = Get-Content ~/.path | |
if ($contents.length -gt $maxline) { | |
$contents | Select-Object -Skip ($contents.length - $maxline) | Set-Content -Encoding utf8 ~/.path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment