Get-Clipboard PowerShell V5

WMF 5 offers this cool cmdlet called Get-Clipboard. This cmdlet let you paste the content of the clipboard into a PowerShell variable and use it in your script. Lets do a simple demo

lets say you have a list of computer like so

get-clipboard

Now lets right click on it and select copy or press crtl+C. Now these server name are in you clipboard. Open a PowerShell Window and type

“Get-Clipboard -Format Text”

get-clipboard2.jpg

The variable $a now has the list on the  server names and it can be used in a foreach loop to perform task on the servers. It is very helpful when testing logic of a script or need to get something done quickly.

get-clipboard3.jpg

There is another cool feature that Get-Clipboard offers when using the parameter -format. You can paste a file structure and PowerShell will return that folder structure  in a object if needed. Lets Take a look

Copy some folders from Windows Explorer

get-clipboard4

Now use the following cmdlet “Get-Clipboard -Format FileDropList” and it will give the folder structure as such

get-clipboard5.jpg

Also it will let you interact with the properties of the object

get-clipboard6.jpg

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s