Set-Clipboard


Записать данные в буфера обмена
Параметры

  • -Value строка, которую нужно записать

  • -Append - добавить текст

  • -Path - путь к файлу/папке, которые нужно скопировать

Примеры

  1. Записать текст в буфера обмена

    Wake up, Neo, select all

    Set-Clipboard "Test string"
  2. Дописать текст в буфер обмена.

    Wake up, Neo, select all

    Set-Clipboard "Hello" # записать текст
    Set-Clipboard "Привет" -Append # дописать текст
  3. Скопировать содержимое файла в буфер.

    Wake up, Neo, select all

    Get-Content "C:\Windows\System32\drivers\etc\hosts" | Set-Clipboard
  4. Скопировать файл в буфер. Тоже самое что клик правой кнопкой по файлу и в меню выбрать копировать.

    Wake up, Neo, select all

    Set-Clipboard -Path "C:\Windows\Media\Alarm01.wav"
  5. Скопировать содержимое папки в буфер.

    Wake up, Neo, select all

    Set-Clipboard -Path "C:\Windows\Media"

полное описание
➡️➡️ ПЕРЕВОД ⬅️⬅️

Изображение


  • Set-Clipboard

    Synopsis

    Sets the current Windows clipboard entry.

    Syntax

    String (Default)

    Код: Выделить всё

    Set-Clipboard [-Append] [-AsHtml] [-WhatIf] [-Confirm] [<CommonParameters>]

    Value

    Код: Выделить всё

    Set-Clipboard [-Value] <String[]> [-Append] [-AsHtml] [-WhatIf] [-Confirm] [<CommonParameters>]

    Path

    Код: Выделить всё

    Set-Clipboard [-Append] -Path <String[]> [-AsHtml] [-WhatIf] [-Confirm] [<CommonParameters>]

    LiteralPath

    Код: Выделить всё

    Set-Clipboard [-Append] -LiteralPath <String[]> [-AsHtml] [-WhatIf] [-Confirm] [<CommonParameters>]

    Description

    The Set-Clipboard cmdlet sets the current Windows clipboard entry.

    Examples

    Example 1: Copy text to the clipboard

    Код: Выделить всё

    Set-Clipboard -Value "This is a test string"

    Example 2: Copy the contents of a directory to the clipboard

    This example copies the content of the specified folder to the clipboard.

    Код: Выделить всё

    Set-Clipboard -Path "C:\Staging\"

    Example 3: Copy the contents of a file to the clipboard

    This example pipes the contents of a file to the clipboard. In this example, we are getting a public
    ssh key so that it can be pasted into another application, like GitHub.

    Код: Выделить всё

    Get-Content C:\Users\user1\.ssh\id_ed25519.pub | Set-Clipboard

    Parameters

    -Append

    Indicates that the cmdlet does not clear the clipboard and appends content to it.

    -AsHtml

    Indicates that the cmdlet renders the content as HTML to the clipboard.

    -LiteralPath

    Specifies the path to the item that is copied to the clipboard. Unlike Path, the value of
    LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the
    path includes escape characters, enclose it in single quotation marks. Single quotation marks tell
    Windows PowerShell not to interpret any characters as escape sequences.

    -Path

    Specifies the path to the item that is copied to the clipboard. Wildcard characters are permitted.

    -Value

    Specifies, as a string array, the content to copy to the clipboard.

    -Confirm

    Prompts you for confirmation before running the cmdlet.

    -WhatIf

    Shows what would happen if the cmdlet runs. The cmdlet is not run.

    Inputs

    System.String[]

    Outputs

    Notes

    In rare cases when using Set-Clipboard with a high number of values in rapid succession, like in a
    loop, you might sporadically get a blank value from the clipboard. This can be fixed by using
    Start-Sleep -Milliseconds 1 in the loop.