mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-21 17:38:19 +02:00
Update cd-home.ps1 and list-workdir.ps1
This commit is contained in:
parent
1cca88c32b
commit
c8efe1f4ec
@ -1,6 +1,6 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the user's home directory
|
Sets the working directory to the user's home folder
|
||||||
.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
|
||||||
@ -13,13 +13,13 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Path = Resolve-Path "$HOME"
|
$Path = Resolve-Path -Path "~"
|
||||||
if (-not(Test-Path "$Path" -pathType container)) {
|
if (Test-Path "$Path" -pathType container) {
|
||||||
throw "Home directory 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
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Path = Resolve-Path "$PWD"
|
$Path = Resolve-Path -Path "$PWD"
|
||||||
"📂$Path"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user