Running PowerShell in Windows 8 (or 8.1) PE Environment
Running PowerShell in Windows 8 (or 8.1) PE Environment
Microsoft promotes the use of PowerShell in Windows 8/8.1. Courseware materials even suggest that MCT’s instruct their students regarding specific PowerShell capability for use in preparing drives, deploying Windows Image Files, and performing trouble shooting operations from the Windows Recovery Environment.
Yet PowerShell is not natively in the Windows PE image or Windows 8/8.1 RE environment.
This blog will provide some basic direction for adding PowerShell to your PE environment so that you can use this powerful command line and scripting tool. Microsoft provides a TechNet article with explicit instructions for the addition of PowerShell to a PE environment, suggesting specifically that it be added during the creation of PE media.
In order to affect this process, you must first download and install the Windows Assessment and Deployment Kit (ADK) for Windows 8/8.1. If you select the minimum components, you will have everything that you need to create the PE media, though you may want to select additional components of the ADK if you are supporting enterprise deployment processes.
Take careful note of the install directory of the Windows 8/8.1 ADK. You will likely need to modify the script provided in the TechNet article, and it is easier if you take note of the install directory BEFORE you attempt to use the script and discover that you need to clean up files and conduct a second pass.
Microsoft TechNet provides a set of instructions for modifying a Windows PE image using DISM to Add PowerShell Support to Windows PE. This works if you are creating a WinPE image, though you need to understand the creation of PE bootable media since several steps are missing. Most notably, the boot.wim file associated with Windows installation and pre-execution environments contains two images: the PE environment and the Windows setup environment. When modifying a boot.wim or PE environment image, it is important to add any drivers, components, or packages to both of the embedded images.
Create the CopyPE directory structure as suggested in the TechNet article by launching the Deployment and Imaging Tools Environment in Administrative Mode.
Run the COPYPE <a> <dest> command, substituting x86, amd64 or arm for <a> and creating a destination directory for <dest>.
I used the recommendation from the TechNet article, since I will be testing on a 64 bit system.
Copype amd64 c:\WinPE_amd64_PS
Note: It does not matter what you name the destination directory, but you do NOT want to create it in advance.
I then copied the Sample Script from the TechNet article and pasted it into a Notepad file. If you take note of the install location for ADK on my system (look at the path in the snapshot above), you will note that installation recommended “Program Files (x86)” rather than merely “Program Files”. As a result, I needed to edit the script file by substituting:
“C:\Program Files (x86)\Windows Kits\8.1” for each instance of “C:Program Files\Windows Kits\8.1”.
I saved the script as a file called CreatePE-PS.cmd.
I then simply ran the .cmd file from the Deployment and Imaging Tools environment that I had already opened in administrative mode.
Now insert a USB drive into your system and take note of the drive letter assigned. (Double check in Windows Explorer). You do not need to format the USB drive. It will be formatted during the process, so make sure you do not select a USB drive containing content that you wish to retain.
I inserted a 2 GB USB 2.0 stick into my system and it was assigned drive letter D.
I ran the command MakeWinPEMedia /UFD C:\WinPE_amd64_PS D:
With the Windows 8.1 ADK, you can create a bootable USB stick without using the utility that I referenced in a previous blog Simplify your Windows 8 Evaluation Install.
Having previously modified my BIOS (UEFI) to bypass fastboot and select my USB port as the primary boot location, I inserted the USB stick and booted into the Windows PE environment.
At the X:\windows\system32> prompt, I typed PowerShell.
Voila…PowerShell tools within the Windows PE environment.
Although I did not experience the issue, some references to the use of PowerShell suggest that you must navigate to the PowerShell directory under the Windows PE root in order to use PowerShell commands.
One related reference by Heath762 Powershell and Windows PE indicates that you may merely need to alter the Environment variables for your PE environment so PowerShell cmdlets are recognized without explicit paths.
You May Also Like
In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management
In this recorded Windows 10 webinar from December 1,2015, Windows Instructor Steve Fullmer presents the navigation and some of the new features associated with Windows 10 including Sysinternals Tools for Windows Client, Windows core concepts, exploring Process Explorer as well as some of the features that are not yet ready for prime time but will … Continue reading Windows 10 Features and Navigation – December 1, 2015
This post is from our recent three-part Windows 10 webinar series. You can watch the video replay of the entire Windows 10 webinars at the following links. Windows 10 Features and Navigation Windows instructor Steve Fullmer introduces the navigation and some of the new features associated with Windows 10 including Sysinternals Tools for Windows Client … Continue reading Windows 10 Basic Desktop and Navigation