Last active
January 25, 2023 13:49
-
-
Save nanoDBA/48f2cd1eab1e4433a97bd106e0dac08d to your computer and use it in GitHub Desktop.
Loop through PSReadline histories for all user profiles and copy them to the clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Get Command Line History for all users | |
# source: https://gist.github.com/nanoDBA/48f2cd1eab1e4433a97bd106e0dac08d | |
$dirs = (Get-ChildItem -Directory (Split-Path $env:USERPROFILE)).FullName | Sort-Object | |
$allHistories = foreach($profileDir in $dirs){ | |
Write-Output "### $profileDir" | |
$historySavePath = "$profileDir\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt" | |
if(!(Test-Path ($historySavePath) )) { | |
Write-Output "### $historySavePath does not exist" | |
} | |
else { | |
Write-Output "# PSReadline $historySavePath " | |
Get-Content $historySavePath | |
} | |
$([environment]::NewLine) | |
} | |
($allHistories).trim() | Set-Clipboard # Copy Command Line History for all users to the clipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment