PowerShell/docs/cd-crashdumps.md

67 lines
1.9 KiB
Markdown
Raw Normal View History

2023-07-29 10:34:04 +02:00
*cd-crashdumps.ps1*
================
2023-05-26 12:20:18 +02:00
2023-10-19 08:12:00 +02:00
This PowerShell script changes the working directory to the crash dumps directory (Windows only). Whenever a software crashes and crash dumps are enabled(!) a crash dump file is written. This file helps to identify the reason for the crash.
2023-05-26 12:20:18 +02:00
2023-07-29 10:04:38 +02:00
Parameters
----------
2023-05-26 12:20:18 +02:00
```powershell
2023-07-29 10:15:44 +02:00
PS> ./cd-crashdumps.ps1 [<CommonParameters>]
2023-05-26 12:20:18 +02:00
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
2023-07-29 10:04:38 +02:00
Example
-------
2023-05-26 12:20:18 +02:00
```powershell
PS> ./cd-crashdumps
📂C:\Users\Markus\AppData\Local\CrashDumps
```
2023-07-29 10:04:38 +02:00
Notes
-----
2023-05-26 12:20:18 +02:00
Author: Markus Fleschutz | License: CC0
2023-07-29 10:04:38 +02:00
Related Links
-------------
2023-05-26 12:20:18 +02:00
https://github.com/fleschutz/PowerShell
2023-07-29 10:04:38 +02:00
Script Content
--------------
2023-05-26 12:20:18 +02:00
```powershell
<#
.SYNOPSIS
Change to the crash dumps folder
.DESCRIPTION
2023-10-19 08:12:00 +02:00
This PowerShell script changes the working directory to the crash dumps directory (Windows only). Whenever a software crashes and crash dumps are enabled(!) a crash dump file is written. This file helps to identify the reason for the crash.
2023-05-26 12:20:18 +02:00
.EXAMPLE
PS> ./cd-crashdumps
📂C:\Users\Markus\AppData\Local\CrashDumps
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
2023-10-19 08:12:00 +02:00
if ($IsLinux) { throw "Sorry, Windows only" }
[string]$path = Resolve-Path -Path "~"
if (!(Test-Path "$path" -pathType container)) { throw "Home directory at $path doesn't exist (yet)" }
$path += "\AppData\Local\CrashDumps"
if (!(Test-Path "$path" -pathType container)) { throw "Crashdumps directory at $path doesn't exist (yet)" }
2023-05-26 12:20:18 +02:00
Set-Location "$Path"
2023-10-19 08:12:00 +02:00
"📂$path"
2023-05-26 12:20:18 +02:00
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
```
2023-10-19 08:12:00 +02:00
*(generated by convert-ps2md.ps1 using the comment-based help of cd-crashdumps.ps1 as of 10/19/2023 08:11:35)*