Detecting WinPE

by | August 29,2018

Table of Contents

Running PowerShell in WinPE Environments

PowerShell can run inside WinPE environments. If you’d like to detect whether your PowerShell script runs inside a WinPE environment, you can simply check whether a special registry key exists:

function Test-WinPE
{
  return Test-Path -Path Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlset\Control\MiniNT
}

Confirming WinPE Status with PowerShell

This function returns $true if you are within a WinPE environment.

Twitter This Tip! ReTweet this Tip!