mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-06 21:16:54 +02:00
Updated cd-root.ps1
This commit is contained in:
parent
b24233e4b7
commit
391c93f9d5
@ -1,11 +1,11 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the root directory
|
Sets the working dir to the root dir
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the current 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
|
.EXAMPLE
|
||||||
PS> ./cd-root
|
PS> ./cd-root.ps1
|
||||||
📂C:\ entered (has 0 files and 7 folders)
|
📂C:\ with 7 folders and 0 files entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,11 +13,11 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) { $path = "/" } else { $path = "C:\" }
|
if ($IsLinux -or $IsMacOS) { $path = "/" } else { $path = "C:\" }
|
||||||
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) folders)"
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
|
"📂$path with $($folders.Count) folders and $($files.Count) files entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ Error: $($Error[0])"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user