November 19, 2020 at 11:00 am #272641ParticipantTopics: 1Replies: 1Points: 14Rank: Member
I am looking how to solve this issue. I need to clean or clear the clipboard.
I need to do this in a windows server 2008 r2.
I have found some instructions like:
- echo off | clip
- (but it only works in CMD or BAT)
Add-Type -AssemblyName System.Windows.Forms[System.Windows.Forms.Clipboard] ::Clear()
- But it only works in powershell ISE and Windows 10 powershell
Any suggestion, please?
November 19, 2020 at 11:29 am #272656ParticipantTopics: 5Replies: 177Points: 686Rank: Major Contributor
What version of powershell do you need this to work on? How about:PowerShell1Set-Clipboard " "
November 19, 2020 at 12:57 pm #272686ParticipantTopics: 2Replies: 382Points: 523Rank: Major Contributor
As Mike suggests, PS version is key if you want to use Set-Clipboard as it was introduced in a later version (5.0?). Although I would suggest using $null rather than an empty string or one with a space in it.PowerShell1Set-Clipboard $null
If the cmdlet isn’t available, you should be able to pipe to clip.exe in PowerShell without any problem if the cmdlet is not available to you. The example you gave isn’t working because in PowerShell echo is an alias for Write-Output.PowerShell1$null | clip.exe
November 23, 2020 at 12:08 pm #273487ParticipantTopics: 1Replies: 1Points: 14Rank: Member
Right, very important.
On this Windows server 2008 r2 is powershell 2.0
November 23, 2020 at 2:07 pm #273541ParticipantTopics: 5Replies: 177Points: 686Rank: Major Contributor
You should still have clip.exe installed so just use it like Matt said. $null | clip.exe
- You must be logged in to reply to this topic.