We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 30c5d76 commit c4faf8fCopy full SHA for c4faf8f
Scripts/cd-etc.ps1
@@ -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