5

Currently I'm trying to figure out how to use Clipboard history in PowerShell.
I know that Get-Clipboard -command shows you the last item in Clipboard, but how to access those 25 others?
Using Windows + V you can see values stored in the history and it has to save those values somewhere in the RAM. On top of that there is file saved in %localappdata%\Microsoft\Windows\Clipboard named HistoryData and under that is some hex file, but I can't figure if that is somehow relevant for my search of if it's just another "Red herring".
(Get-Clipboard).count only shows 1.

  • everything i can find online says that the data is stored in RAM ... so you likely need to use a call to some part of windows to grab that info. i can't find anything on how to do that, tho. [*sigh ...*] – Lee_Dailey May 03 '22 at 09:21
  • 1
    Use `Windows.ApplicationModel.Clipboard.GetHistoryItemsAsync` in conjunction with [awaiting from PowerShell](https://stackoverflow.com/questions/21194315/) to get the `ClipboardHistoryItemsResult`. You can then iterate through the `Items` and call `GetTextAsync` (say) to get the text of each history item. – Raymond Chen May 05 '22 at 16:11
  • how exactly? what command in powershell? @Raymond Chen – bpfrd Oct 19 '22 at 14:26
  • https://devblogs.microsoft.com/oldnewthing/20230303-00/?p=107894 – EMBarbosa Mar 25 '23 at 18:17

1 Answers1

0

If you look at the documentation for the command using Get-Help Get-Clipboard you will see that it really does only show you the current entry - not a full history

NAME
    Get-Clipboard

SYNOPSIS
    Gets the current Windows clipboard entry.
Panomosh
  • 884
  • 2
  • 8
  • 18