mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-11 16:39:10 +01:00
Updated cd-home.ps1
This commit is contained in:
parent
2e75436637
commit
65a0858f7a
@ -4,7 +4,7 @@
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's home directory.
|
This PowerShell script changes the working directory to the user's home directory.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-home
|
PS> ./cd-home.ps1
|
||||||
📂C:\Users\Markus
|
📂C:\Users\Markus
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -13,13 +13,11 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Path = Resolve-Path -Path "~"
|
$path = Resolve-Path "~"
|
||||||
if (Test-Path "$Path" -pathType container) {
|
if (-not(Test-Path "$path" -pathType container)) { throw "Home folder at $path doesn't exist (yet)" }
|
||||||
Set-Location "$Path"
|
Set-Location "$path"
|
||||||
"📂$Path"
|
"📂$path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
}
|
|
||||||
throw "User's home folder at 📂$Path doesn't exist (yet)"
|
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user