How to Write Clipboard to File
How to Write Clipboard to File
September 26, 2022
Have you ever wondered how to persist your clipboard to disk? Wonder no more…
To get started, copy a random sentence into your clipboard like so:
Set-Clipboard -Value "This is being copied into clipboard"Let’s confirm the contents of the clipboard, like so:
Get-Clipboardoutput:
This is being copied into clipboardWe’ll now persist the same cliboard to a file, like so:
Get-Clipboard | Out-File -FilePath clipboard.txtTo confirm the contents of this file, we type:
Get-Content .\clipboard.txtoutput:
This is being copied into clipboardLet’s append something else into the clipboard like so:
Set-Clipboard "appended!" -AppendAnd finally, we confirm that this text has indeed been copied into the clipboard like so:
Get-Clipboardoutput:
This is being copied into clipboard
appended!There you have it, a short post on how to obtain and set the clipboard using Powershell commands.
Module: Microsoft.PowerShell.Management
Last updated on