Set-Clipboard
Sets the current Windows clipboard entry.
Sintaks
String (Default)
Set-Clipboard
[-Append]
[-AsHtml]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Value
Set-Clipboard
[-Value] <String[]>
[-Append]
[-AsHtml]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Path
Set-Clipboard
-Path <String[]>
[-Append]
[-AsHtml]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
LiteralPath
Set-Clipboard
-LiteralPath <String[]>
[-Append]
[-AsHtml]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Deskripsi
The Set-Clipboard
cmdlet sets the current Windows clipboard entry.
Contoh
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, a public ssh key, to the clipboard. Then, the key can be pasted into another application, like GitHub.
Get-Content C:\Users\user1\.ssh\id_ed25519.pub | Set-Clipboard
Parameter
-Append
Indicates that the cmdlet should add to the clipboard instead of replacing it. By default, the cmdlet clears the current content from the clipboard and sets it to the new content. When this parameter is specified, the cmdlet appends the new content after a newline to the current content.
Properti parameter
Jenis: | SwitchParameter |
Nilai default: | None |
Mendukung wildcard: | False |
DontShow: | False |
Set parameter
(All)
Position: | Named |
Wajib: | False |
Nilai dari alur: | False |
Nilai dari alur berdasarkan nama properti: | False |
Nilai dari argumen yang tersisa: | False |
-AsHtml
Indicates that the cmdlet renders the content as HTML to the clipboard.
Properti parameter
Jenis: | SwitchParameter |
Nilai default: | None |
Mendukung wildcard: | False |
DontShow: | False |
Set parameter
(All)
Position: | Named |
Wajib: | False |
Nilai dari alur: | False |
Nilai dari alur berdasarkan nama properti: | False |
Nilai dari argumen yang tersisa: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Properti parameter
Jenis: | SwitchParameter |
Nilai default: | False |
Mendukung wildcard: | False |
DontShow: | False |
Alias: | cf |
Set parameter
(All)
Position: | Named |
Wajib: | False |
Nilai dari alur: | False |
Nilai dari alur berdasarkan nama properti: | False |
Nilai dari argumen yang tersisa: | False |
-LiteralPath
Specifies the path to the item that's copied to the clipboard. Unlike Path, the value of LiteralPath is used exactly as it's written. 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.
Properti parameter
Jenis: | String[] |
Nilai default: | None |
Mendukung wildcard: | False |
DontShow: | False |
Alias: | PSPath |
Set parameter
LiteralPath
Position: | Named |
Wajib: | True |
Nilai dari alur: | False |
Nilai dari alur berdasarkan nama properti: | True |
Nilai dari argumen yang tersisa: | False |
-Path
Specifies the path to the item that's copied to the clipboard. Wildcard characters are permitted.
Properti parameter
Jenis: | String[] |
Nilai default: | None |
Mendukung wildcard: | True |
DontShow: | False |
Set parameter
Path
Position: | Named |
Wajib: | True |
Nilai dari alur: | False |
Nilai dari alur berdasarkan nama properti: | True |
Nilai dari argumen yang tersisa: | False |
-Value
Specifies, as a string array, the content to copy to the clipboard.
Properti parameter
Jenis: | String[] |
Nilai default: | None |
Mendukung wildcard: | False |
DontShow: | False |
Set parameter
Value
Position: | 0 |
Wajib: | True |
Nilai dari alur: | True |
Nilai dari alur berdasarkan nama properti: | True |
Nilai dari argumen yang tersisa: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet isn't run.
Properti parameter
Jenis: | SwitchParameter |
Nilai default: | False |
Mendukung wildcard: | False |
DontShow: | False |
Alias: | wi |
Set parameter
(All)
Position: | Named |
Wajib: | False |
Nilai dari alur: | False |
Nilai dari alur berdasarkan nama properti: | False |
Nilai dari argumen yang tersisa: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Input
String
You can pipe a string containing the content to set to the clipboard to this cmdlet.
Output
None
This cmdlet returns no output.
Catatan
Windows PowerShell includes the following aliases for Set-Clipboard
:
scb
In rare cases, when using Set-Clipboard
many times in rapid succession, like in a loop, the
clipboard isn't updated or you receive an ExternalException error. This can be caused when you
try to set the clipboard and it's still in use. This can try to avoid this problem by adding
Start-Sleep -Milliseconds 100
to the loop.