What causes the clickboard to be cleared after a PS cmd is executed?

Welcome Forums General PowerShell Q&A What causes the clickboard to be cleared after a PS cmd is executed?

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
7 months, 2 weeks ago.

  • Author
    Posts
  • #93198

    Participant
    Points: 1
    Rank: Member

    Hi,

    I've been curious about this behavior for years, but I've chosen to just live with it. Enough of that.

    Does anyone know why the clipboard is sometimes cleared after certain commands are executed? For example, if my clipboard contains a computer name, and I paste that name into a line that's doing a Test-Connection call and execute it, it may clear that computer name from my clipboard. But not consistently. It happens enough for me to believe it's intentional, but I don't know what causes it.

    Thanks,
    Joel

  • #93202

    Participant
    Points: 229
    Helping Hand
    Rank: Participant

    This is not a PoSH issue, it is a Windows clipboard limitation/oddity. it's an 1:1 thing. The moment anything (you, some other process, action, activity) interacts with the clipboard for any reason, that is what you have on the clipboard.

    There are Windows add-ons / extension the purport one to have multiple clips on the clipboard. For example this one I experimented with the past.

    Clipboard Manager
    'sourceforge.net/projects/clipman'

    Yet, nothing PoSH can do about this natively.

    So, it's prudent to keep stuff you plan to reuse in a static variable in your code, or you need a better clipboard option.

  • #97897

    Participant
    Points: 1
    Rank: Member

    Thanks, but I don't agree. Say I have a computer name in my clipboard. I paste it into my PS console and execute a ping command with it. When the ping completes, I try to paste it again but it is no longer in the clipboard. However, it isn't consistently removed from the clipboard, so it's tough to point to the exact cause, but I don't believe it's solely Window's issue.

The topic ‘What causes the clickboard to be cleared after a PS cmd is executed?’ is closed to new replies.