Skip to content

Commit c4faf8f

Browse files
author
Markus Fleschutz
committed
Add cd-etc.ps1 script
1 parent 30c5d76 commit c4faf8f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Scripts/cd-etc.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<#
2+
.SYNOPSIS
3+
Changes to the /etc directory
4+
.DESCRIPTION
5+
This PowerShell script changes the working directory to the /etc directory.
6+
.EXAMPLE
7+
PS> ./cd-etc
8+
📂C:\Windows\System32\drivers\etc
9+
.LINK
10+
https://github.com/fleschutz/PowerShell
11+
.NOTES
12+
Author: Markus Fleschutz | License: CC0
13+
#>
14+
15+
try {
16+
if ($IsLinx) {
17+
$Path = "/etc"
18+
} else {
19+
$Path = Resolve-Path "$env:WINDIR\System32\drivers\etc"
20+
}
21+
if (-not(Test-Path "$Path" -pathType container)) {
22+
throw "/etc directory at 📂$Path doesn't exist (yet)"
23+
}
24+
Set-Location "$Path"
25+
"📂$Path"
26+
exit 0 # success
27+
} catch {
28+
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
29+
exit 1
30+
}

0 commit comments

Comments
 (0)