mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-06 21:16:54 +02:00
Updated cd-users.ps1
This commit is contained in:
parent
03d931f4e8
commit
3d31f68b4b
@ -1,11 +1,11 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the users directory
|
Sets the working dir to the users directory
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the users directory.
|
This PowerShell script sets the current working directory to the users directory.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-users
|
PS> ./cd-users.ps1
|
||||||
📂C:\Users entered (has 0 files and 4 subfolders)
|
📂C:\Users with 4 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -15,12 +15,11 @@
|
|||||||
try {
|
try {
|
||||||
$path = Resolve-Path "~/.."
|
$path = Resolve-Path "~/.."
|
||||||
if (-not(Test-Path "$path" -pathType container)) {
|
if (-not(Test-Path "$path" -pathType container)) {
|
||||||
throw "No users directory at $path"
|
throw "No users directory at: $path"
|
||||||
}
|
}
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
"📂$path with $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ Error: $($Error[0])"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user