Weekend Scripter: Install PowerShell 4.0 in Windows 7


Summary: Windows PowerShell MVP, Teresa Wilson, talks about upgrading Windows PowerShell 2.0 to Windows PowerShell 4.0 in Windows 7.

Hello everyone. The Scripting Wife, here. The Scripting Guy is off reading a book—I think it may be Rob Roy by Walter Scott, but I am not sure. He seems to be on a Walter Scott kick lately. I have little interest in a book that has to come in two or more volumes, so I was looking over the recent Hey, Scripting Guy! Blog posts about upgrading to Windows PowerShell 4.0. I realized that the Scripting Guy had forgotten to say exactly how to upgrade. I mean, really. Like everyone is going to magically know how to do this stuff. So here I go…

I know that Windows 7 has been out for a while—actually, a pretty good while, and  there is no telling what all has been added, updated, or changed.  So I thought I should start at the beginning.  

I got the Windows 7 ISO from MSDN (that is, Windows 7 Professional), and it had the Service Pack installed. That is it. I went through the defaults. I did a standalone install, and did not join a domain. I did give the installation a name, and that was about it. It took me around 45 minutes to do this. When the installation  was complete, I opened Windows PowerShell to check the version number. As shown here, it was Windows PowerShell 2.0:

Image of command output

I then decided to check for updates. Windows Update showed that there was nearly a gigabyte worth of updates, so I figured it might take a while. I selected all of the important updates and three of the optional updates. It did not make sense that these were optional. All I could see was some sort of KB numbers. There was no description other than something about being related to stability and optimization. If an update makes Windows more stable and more optimized, why is it not important? Hey, don’t ask me. Anyway, this is what I have so far:

Image of menu

Well, downloading and installing that many updates will take a while. I think I am going to go make a cup of hot chocolate, maybe grab a Hershey bar, and then come back…

I'm back. To be honest, it was enough time for two cups of hot chocolate, two Hershey bars, a bag of popcorn, a soda, and a ham and cheese sandwich. It now says it is preparing to install. I'm not sure exactly what it is preparing—but anyway, it is still prepping.

When it is done installing the 167 updates, I reboot and take a snapshot of the virtual machine, sign in again, and check for more updates. It finds about an additional fifty updates, so I go through the process again…

Now I click the Start button, and in the Search box, I type PowerShell. Windows quickly finds the following:

  • Windows PowerShell
  • Windows PowerShell (x86) in both ISE and console flavors
  • PowerShell modules

Neat. I know I am supposed to be going through these things without making any changes. But hey, I can’t help it—I right-click both the Windows PowerShell and the Windows PowerShell ISE icons and select Add Pin to Task Bar from the action menu. No matter what, Windows doesn’t look right to me without the friendly Windows PowerShell icons prominently displayed.

I right-click the Windows PowerShell console icon and select Run as Administrator from the action menu. I am curious about how many hotfixes I installed. So I type the following command:

Get-HotFix | measure

It tells me that I installed 178 hotfixes. Wow. I am sure glad that Windows PowerShell has the Get-HotFix cmdlet to tell me these things.

I decide that I want to double-check the version of Windows PowerShell. So I use the $PSVersionTable automatic variable, and it tells me the PSVersion is still Windows PowerShell 2.0.

I need to find out what version of Windows I have installed. I will need to know this information if I am going to download the right version of Windows PowerShell 4.0. Do I have a 64-bit or 32-bit installation of Windows 7? I can use the following command to find this information:

$env:PROCESSOR_ARCHITECTURE

It says I have AMD64, so I guess this means that I have a 64-bit version of Windows installed. The good thing is that if I get this wrong, the installer will tell me—so it is not like I will end up hosing my computer. Plus, because I am doing this in a virtual machine, if I do hose things, I can easily shut down, and revert to my latest snapshot.

The easiest way to find Windows PowerShell 4.0 is to go to the Microsoft Script Center home page, and select Windows PowerShell 4.0 from the Scripting Downloads section.

After the final update, I navigate to the Download Center so I can grab the bits for Windows PowerShell 4.0. This is a bit confusing because it is not called Windows PowerShell 4.0—it is called Windows Management Framework 4.0. Here is what the download page looks like:

Image of menu

After I click the Download button, I choose the appropriate package. It is also a good idea to grab the Release Notes. They are excellent, and they talk about various compatibility issues with certain network and management applications. There are also two Desired State Configuration references that look pretty interesting, so I also grab them. Here is what the page looks like:

Image of menu

After I make my selections and click Next, a dialog box appears at the bottom of the screen asking me to disable the popup blocker. I say OK, and I am prompted as to where to download the files. I choose the FSO folder, and again I am prompted for each of the items I checked.

I go to my c:\fso folder, double-click the update file, and see a prompt asking me if I want to install Update for Windows (KB2819745). I say yes, but I wonder why it did not ask me if I wanted to install Windows PowerShell 4.0, or at least Windows Management Framework 4.0. Oh, well, so now there are three different names.

I click OK, and I am prompted with the license terms shown in the following image. It mentions Windows Management Framework 4.0, so I feel a bit more comfortable. However, it seems to me that the buttons are reversed. Hmm…tricky. I click I Accept.

Image of menu

Finally, the updates are being installed—updates that I know and that I really want. WooHoo!

It goes…and goes…

Installing update 1 of 1…

Still installing…the little green progress bar is steadily marching to the right side of the screen. I'm holding my breath. Please, please, please don’t fail. The bar just moved over a big jump…one more big jump. It is nearly there. Yes! The installation is complete! Now one more simple reboot.

Image of menu

I click Restart Now. The computer does a little bit of update configuring, shuts down, and then starts Windows. I see the red, green, blue, and lime flag, and I anxiously wait to sign in. Nope, please wait…

It is configuring Windows Updates—70 percent complete, 80, 83, 85, 90, 91 93, 95, 96, 97, 98, percent complete—and finally, the sign-in screen.

“Welcome," it says. How friendly. Now for the big test. I click the icon that I made in the Windows PowerShell 2.0 days (as you recall, this was a single update ago), and Windows PowerShell opens really fast. I notice that the Copyright date has changed, and I type $PsVersionTable. Sure enough! As you can see in the following image, I am now running Windows PowerShell 4.0:

Image of command output

That really was easy. I installed Windows 7, ran all the default updates, then downloaded the Windows Management Framework 4.0 (also known as Update for Windows (KB2819745) and Windows PowerShell 4.0), rebooted, and it worked. That was it. Easy as baking a pie. And now I have access to all the great Windows PowerShell 4.0 stuff.

That is it for now. Hope you have a great weekend.

~Teresa

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 (15)

  1. LibertyGuy62 says:

    I’d like to echo George’s comment. Is there a silent way to push this out to an enterprise?

  2. Jon W says:

    A big gotcha is that .NET Framework 4.5 is a prerequisite for WMF 4.0. It won’t warn you if it isn’t installed; it’ll simply not work. Read more here:

    http://blogs.msdn.com/b/powershell/archive/2013/10/29/wmf-4-0-known-issue-partial-installation-without-net-framework-4-5.aspx

  3. Shaniequa says:

    Came here to say exactly what Jon W said.

  4. Sean says:

    Thanks Teresa, this was a big help. In particular I would have had no idea that I needed to download the Windows6.1 version for Windows 7. Makes little sense to me but I just followed your lead and it worked!

  5. George says:

    Is there any way this can be done automatically, by some sort of powerfull shell scripting language by chance?

  6. ITGuy says:

    Nice little tutorial, ditto on Jon W. Took me 30 min. to figure out that i needed .NET 4.5 for this thing to work. Wish I had read the comments before all this, would be cool if you could edit the above to point that out 🙂

  7. Craig C says:

    use the /quiet command

  8. Craig C says:

    But I’m looking for is a way to suppress the reboot, so I can reboot later when other scripts and processes are finished.

  9. Osiyo Wado says:

    Super, thanks for the very friendly walk through the forest, and now I am one happy camper running PowerShell 4.0 on my Windows 7 Enterprise. I suffer from ALS and am looking to create desktop buttons that would open web links and log people into applications,
    as we have problems with clicks and other things, one button could save 5 or more clicks, be blessed as I am blessed. sumnjer@online.de Help if one can and is willing for we one day become paralyzed with only our eyes to work a PC and stay in touch with the
    outside world. Humbly yours

  10. DwightH says:

    Many thanks for the uppertunity to learn how to install PowerShell 4.0.

  11. jbruns2010 says:

    Too bad it never works the way its documented. Running W7 Ultimate N with SP1 and after installing .Net 4.6 and rebooting, running the Windows6.1-KB2819745-x64-MultiPkg.msu file results in a pop-up that states ‘searching for updates on this computer’ and
    hours go by with no changes. Nice.

  12. jbruns2010 says:

    Update:

    Apologies to MS. Kaspersky v14 was the culprint, like A/V always is. Removed A/V and tried install again. Worked right away.

    When is someone going to make an A/V tool that gets out of the way of normal everyday work?

    1. Brett says:

      McAfee’s did the same thing to me.

Skip to main content