Skip to content

Instantly share code, notes, and snippets.

@Tiberriver256
Created June 26, 2020 00:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tiberriver256/d8ee82398827423c35ea4066be532f44 to your computer and use it in GitHub Desktop.
Save Tiberriver256/d8ee82398827423c35ea4066be532f44 to your computer and use it in GitHub Desktop.
<#
.SYNOPSIS
Copy files using your clipboard and PowerShell
.DESCRIPTION
The file specified at $Path is converted to a base64 string, wrapped with a tiny script that converts the base64 string
back to binary and saves it at the path specified in the $Destination parameter
#>
function Copy-PasteItem {
[CmdletBinding()]
param (
# The path of the file you would like to copy
[string]$Path,
# The destination file path you would like the file created
[string]Destination
)
$Base64File = [System.Convert]::ToBase64String((Get-Content -Path $Path -Encoding Byte -ReadCount 0))
"[System.Convert]::FromBase64String('$Base64File') | Set-Content '$Destination' -Encoding Byte -Verbose; Write-Host 'Your file is ready at $Destination'" | clip
Write-Host "Open Powershell on the remote computer and paste to create your file at $Destination"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment