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:
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:
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:
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:
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:
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.
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.
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:
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.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy