I am relatively new to PowerShell and an having a problem right from the start. Once I have copied a File to the Clipboard, how can I then retrieve it via a PS Script, and Save it to a pre-determined Folder? Thanks in advance.
Saving can be done based on what you have in the clipboard. If its a text then
Out-File will be the best option.
Thanks for the swift response. I actually have a copied Filed in the Clipboard, that i need to now Save to a Folder.
My apologies, I actually have an Image (*.jpg) in the Clipboard that I would like to Save as a File in a Folder.
AFAIK, there is no direct way to save it as a file from clipboard using a cmdlet. If it is a copy from a file system like using Ctrl + C from a filder, the you can use
Get-Clipboard -Format FileDropList, but there is no way to save it.
But if it is from a temp source, like from a snipping tool output or from a pdf, word doc etc. Then
$FileFromClipboard = Get-Clipboard -Format Image $FileFromClipboard | Get-Member -MemberType Method # This should have a save method in it. $FileFromClipBoard.Save("C:\temp\Image.png")
The Script worked perfectly, thanks. I am still a little confused, what is the ‘literal’ Translation of the three lines? Thanks again for your help in this matter, I never would have gotten this.
Only the first and third lines are required, the second line is used just to confirm you have the right type of object.
$FileFromClipboard = Get-Clipboard -Format Image
This line takes the contents of your clipboard, specifying the data is in image format, and stores it in the variable $FileFromClipBoard
This line takes the image data contents of that variable and saves it to C:\Temp\image.png
You could also skip the variable altogether:
(Get-Clipboard -Format Image).Save("C:\temp\Image.png")
Thank you for the explanation.