Cool Stuff about PowerShell 5.0 in Windows 10


Summary: Ed Wilson, Microsoft Scripting Guy, talks about cool stuff in Windows PowerShell 5.0 for Windows 10.

Microsoft Scripting Guy, Ed Wilson, is here. Over the weekend, I installed Windows 10. It is way cool. I love what we have done with the charms bar…it is gone. I also like the streamlined user interface, the new Edge browser, and especially Windows PowerShell 5.0. I mean, it is awesome. It rocks.

By the way, the easiest way to upgrade to Windows PowerShell 5.0 right now, is to upgrade to Windows 10—which by the way, is a free upgrade from Windows 7, 8, and 8.1. For now, that is what I am going to be doing—talking about Windows PowerShell 5.0 on Windows 10. And this brings me to Cool Stuff Week...

What is so cool about PowerShell 5.0?

Well, first of all, what’s not cool? Pretty much nothing. I love it. When I install Windows 10, I have Windows PowerShell 5.0. As Teresa explained yesterday, the next step is to pin Windows PowerShell to the Start page and to the Taskbar (see Exploring Windows PowerShell 5.0). I do this for the ISE and for the Windows PowerShell console.

I am not going to enable scripting right now. I will do that later. For now, I am exploring. I also need to open Windows PowerShell as an Administrator and update Help. Teresa also talked about how to do that yesterday.

The Clipboard

I will admit that when I first heard about Get-Clipboard and Set-Clipboard, I figured they would be pretty lame. I mean, I have been piping to Clip.exe for years. In addition to that, there are Clipboard cmdlets in the PowerShell Community Extension Project, so I figured this was just some low hanging fruit that was easy for the Windows PowerShell team to add.

Really, though, it is pretty cool.

First of all, I can pipe strings to Set-Clipboard and then get it back via Get-Clipboard. It works as expected.

But, when I pipe a directory list to Set-Clipboard, and then I use Get-Clipboard, I don’t get anything back—until I specify the format I want as a FileDropList. As shown here, I then get back a collection of objects:

Image of command output

Of course, it should come as no surprise that we have an object-oriented Clipboard. I mean, everything in Windows PowerShell is an object, so why not the Clipboard? This also means that I can index into the Clipboard, and return a FileInfo object. This is shown here:

Image of command output

At this point, I am starting to think, “You have got to be kidding. Really? Objects on the Clipboard?” Dude, dude, dude."

I know how to use objects and how to work with collections of objects. I mean, this is awesome stuff. I can grab only the base names from the collection of objects, or I can create a table with the base name and the last access time—all from the same Clipboard content. This is shown here:

Image of command output

So, yeah. The Clipboard cmdlets are cool. Way cool. And that is just two of the 1,285 Windows PowerShell cmdlets in Windows 10.

That is just scratching the surface of Windows PowerShell 5.0. Join me tomorrow when I will talk about more cool stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

Comments (19)

  1. mohit.goyal says:

    No surprise, its using a generic collection. Does it restrict generic to list type or something else?

  2. That does look cool! Just to be a pedant though, "is a free upgrade from Windows 7, 8, and 8.1", I believe it’s only 7 and 8.1, not 8.0! 🙂

  3. PowerShell Fan says:

    Anyone facing the consistent problem where Function keys no longer work in the new PowerShell 5 command console in Windows 10 RTM?

    e.g.
    in previous versions, it is possible to press F2 followed by a key (such as a space in this example) and get the last typed command up to that position.

    gsv vss

    [tag:hit] F2 then press space
    gsv

    Thanks!

  4. One of the fun things I noticed is that you can CTRL+V in the console. I tend to do a lot inside the ISE and sometimes have been know to switch over to a clean console and in the heat of the moment hit CTRL+V and just receive the ^V at the prompt. When
    I dropped the new hotness on my computer again completely by accident I noticed that when I hit the CTRL+V combo, what I had pasted into my clipboard popped into my console!

    Good Work all around!

  5. codekaizen says:

    For the pendants, out there, this may help: 8.0 -> 8.1 is a free upgrade, so, if we sum the cost of the upgrade and use the sum to represent the final cost of the upgrade, we see that it is in fact still free.

  6. Fanny says:

    The pedants will be worried about your spelling

  7. Can confirm with PowerShell Fan about the function keys no longer working – I used to use the F7 key to bring up a list of the last 10 typed commands.

    1. Yuriy says:

      Hello,

      While we have PSReadLine embedded , you may want use predefined Ctrl+R (reverse history search) and Ctrl+S (forward history search).
      I know, it may hurt changing habits, however these shortcuts will help you searching interactively. Even better, it will not run the command right after you hit enter as older F7 does.
      You may always want to run Get-PSReadlineKeyHandler to see available keyboard shortcuts.
      And, yes, there is Set-PSReadlineKeyHandler cmdlet, so feel free to assign F7 to history search function. Also, you can assign key sequences to your own functions.

      Enjoy exploring!

      Thank you,
      Yuriy

  8. Ed Wilson says:

    What we have in PowerShell 5 is PSReadline starting up and running by default. For now, see my prior articles about PSReadline
    http://blogs.technet.com/b/heyscriptingguy/archive/tags/psreadline/ To revert to "old behavior" unload the PSReadline module in your profile Remove-Module PSReadline

  9. HicanNL says:

    Can you fill the Clipboard with Set-Clipboard (so making use of PowerShell) and then paste that data with Ctrl-V in, for example, notepad? That would be kinda cool. I have to fiddle around with this 🙂

  10. PowerShell Fan says:

    @campbell_kerr
    @Ed Wilson

    Where can one report (serious) bugs like this that should not even have slipped through into RTM in the first place, since classic "MS-DOS" support, including common keyboard shortcuts, etc. is key to help IT Pros and administrators transit smoothly over to
    PowerShell?

    Thanks!

  11. Help for Help says:

    As Windows 10 is released and contains new PowerShell commands, when do we get the help for these new PowerShell commands?
    Do we have to wait until Windows Server 2016 releases?

    Examples:
    Get-Help Set-Clipboard -Detailed
    Get-Help Set-Clipboard -Online
    Get-Help Clear-RecycleBin -Detailed
    Get-Help Clear-RecycleBin -Online

  12. Disappointed says:

    @Help for Help

    It appears that we cannot expect to get any clear help or official response unfortunately, here or in the Microsoft Forum with regards to such "shortcomings" (or bugs?), a step back from what used to work and now obviously broken.

    Fortunately though, you should be able to use Update-Help -force to download and save a local copy of PowerShell help system if the latter for PS 5.0 version is available. Bear in mind though that Windows 10 and higher is now positioned as "Windows As a Service"
    so various components of the OS may never ever be considered finish or complete.

  13. MGSBoca says:

    And what may I ask do you do with this information?

  14. Tamothy says:

    psreadline being enabled means you are not able to write an "if else" without calling it from a script file… feels like a step backwards

  15. Andrew says:

    Can you make it arbitrarily wide using only the mouse?

    1. Greg says:

      Ed,
      Will powershell allow for UTF-8 display on the screen?
      In other words, can I use a type fname.txt command where fname.txt contains Russian, Mongolian, Chinese text and actually get the Unicode characters to display as output?
      Thanks,
      Greg

Skip to main content