Execution Policy

There are a few ways to set the PowerShell Execution Policy in WinSE. I'll start with the easiest

AutoUnattend.xml Method

By far the easiest way to set the PowerShell Execution Policy to Bypass is to use an AutoUnattend.xml with a RunSynchronous Command

1
<settings pass="windowsPE">
2
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
<UserData>
4
<AcceptEula>true</AcceptEula>
5
<ProductKey>
6
<Key>NPPR9-FWDCX-D2C8J-H872K-2YT43</Key>
7
<WillShowUI>Never</WillShowUI>
8
</ProductKey>
9
</UserData>
10
<RunSynchronous>
11
<RunSynchronousCommand wcm:action="add">
12
<Order>1</Order>
13
<Description>OSD ExecutionPolicy</Description>
14
<Path>PowerShell -WindowStyle Hidden -Command "Set-ExecutionPolicy Bypass"</Path>
15
</RunSynchronousCommand>
16
</RunSynchronous>
17
</component>
18
</settings>
Copied!

That does the trick

Driver Method (OSDBuilder)

You can easily create your own Driver INF and add that to WinSE (WinPE and WinRE too) to set the Execution Policy. OSDBuilder easily lets you add this Driver

RegAdd PowerShell ExecutionPolicy.inf
1
;==================================================================================================
2
; David Segura
3
; https://www.osdeploy.com
4
;==================================================================================================
5
; Purpose: Set PowerShell ExecutionPolicy to Bypass
6
;==================================================================================================
7
; Compatibility: WinPE 10 x86 and x64
8
;==================================================================================================
9
[Version]
10
Signature = "$WINDOWS NTquot;
11
Class = System
12
ClassGuid = {4D36E97d-E325-11CE-BFC1-08002BE10318}
13
Provider = OSDeploy
14
DriverVer = 10/19/2018,2018.10.19.0
15
16
[DefaultInstall]
17
AddReg = AddReg
18
19
[AddReg]
20
;rootkey,[subkey],[value],[flags],[data]
21
;0x00000 REG_SZ
22
;0x00001 REG_BINARY
23
;0x10000 REG_MULTI_SZ
24
;0x20000 REG_EXPAND_SZ
25
;0x10001 REG_DWORD
26
;0x20001 REG_NONE
27
HKLM,SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell,ExecutionPolicy,0x00000,"Bypass"
Copied!
Last modified 2yr ago