PowerShell/scripts/cd-logs.ps1

30 lines
618 B
PowerShell
Raw Normal View History

2024-10-01 15:11:03 +02:00
<#
2023-05-26 14:19:58 +02:00
.SYNOPSIS
Sets the working directory to the logs folder
.DESCRIPTION
This PowerShell script changes the current working directory to the logs directory.
.EXAMPLE
PS> ./cd-logs
📂/var/logs
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
function GetLogsDir {
if ($IsLinux) { return "/var/logs" }
$WinDir = [System.Environment]::GetFolderPath('Windows')
return "$WinDir\Logs"
}
try {
2024-10-30 13:19:56 +01:00
$path = GetLogsDir
Set-Location "$path"
"📂$path"
2023-05-26 14:19:58 +02:00
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
2024-10-30 13:19:56 +01:00
}