thisisxiaozhu 在 powershell命令行技巧,如何在命令行实现C-c复制文件/复制文件内容的效果 中发帖
封装了一个powershell函数
function Copy-ToClipboard {
param (
[Parameter(Position = 0, Mandatory = $true)]
[string]$FilePath,
[Parameter()]
[Alias('f')]
[switch]$CopyFile
)
if (-not (Test-Path $FilePath)) {
Write-Host "[ERROR] File not found: $FilePath"
return
}
try {
if ($CopyFile) {
$absolutePath = ...