mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-23 05:01:37 +01:00
Update cd-root.ps1
This commit is contained in:
parent
69b9544a21
commit
2f8187cb82
@ -2,10 +2,9 @@
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the root directory
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the root directory (C:\ on Windows).
|
||||
This PowerShell script changes the current working directory to the root directory (C:\ on Windows).
|
||||
.EXAMPLE
|
||||
PS> ./cd-root
|
||||
📂C:\
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,14 +12,7 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = resolve-path "/"
|
||||
} else {
|
||||
$Path = resolve-path "C:\"
|
||||
}
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Root directory at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
if ($IsLinux) { $Path = "/" } else { $Path = "C:\" }
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
|
Loading…
Reference in New Issue
Block a user