How can we help?
Welcome to our Support Portal. Search for answers using the search box below.,
Copy Powershell Clipboard To A TXT File –
Option 1: The Quickest Method (Using Redirection)
This uses the shorthand alias gcb for Get-Clipboard and redirects it directly into a file.
powershell
gcb > output.txt
(Note: This creates output.txt in your current working directory. You can also specify a full path like gcb > C:\Folder\output.txt.)
Option 2: The Standard Method (Using Out-File)
This explicitly routes the text data and is safer for managing specific text encodings (like UTF8).
powershell
Get-Clipboard | Out-File -FilePath "output.txt" -Encoding utf8
Option 3: Appending to an Existing File
If the .txt file already exists and you want to add the clipboard contents to the bottom of it instead of overwriting it, use Add-Content:
powershell
Get-Clipboard | Add-Content -Path "output.txt"