Skip to content

Commit 8cf0a23

Browse files
author
Markus Fleschutz
committed
Add cd-logs.ps1
1 parent ea63371 commit 8cf0a23

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Scripts/cd-logs.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<#
2+
.SYNOPSIS
3+
Sets the working directory to the logs folder
4+
.DESCRIPTION
5+
This PowerShell script changes the current working directory to the logs directory.
6+
.EXAMPLE
7+
PS> ./cd-logs
8+
📂/var/logs
9+
.LINK
10+
https://github.com/fleschutz/PowerShell
11+
.NOTES
12+
Author: Markus Fleschutz | License: CC0
13+
#>
14+
15+
function GetLogsDir {
16+
if ($IsLinux) { return "/var/logs" }
17+
$WinDir = [System.Environment]::GetFolderPath('Windows')
18+
return "$WinDir\Logs"
19+
}
20+
21+
try {
22+
$Path = GetLogsDir
23+
Set-Location "$Path"
24+
"📂$Path"
25+
exit 0 # success
26+
} catch {
27+
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
28+
exit 1
29+
}

0 commit comments

Comments
 (0)