Skip to content

Instantly share code, notes, and snippets.

@kentork
Created November 29, 2017 05:53
Show Gist options
  • Save kentork/9488a9bd0bdeb0384aaab2c1bedcf404 to your computer and use it in GitHub Desktop.
Save kentork/9488a9bd0bdeb0384aaab2c1bedcf404 to your computer and use it in GitHub Desktop.
Path Backup
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