From 63e8f57e282a8844d48cb9b34fca910e5a8d5a04 Mon Sep 17 00:00:00 2001 From: Homes32 Date: Sat, 22 Jun 2024 14:18:26 -0500 Subject: [PATCH] Added the option to configure the Execution Policy on Powershell scripts. --- .../System Tools/PowerShellCore.script | 13 +++++-- .../PhoenixPE/Components/EventLogging.script | 2 +- .../Components/WindowsPowerShell.script | 35 +++++++++++++------ 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Projects/PhoenixPE/Applications/System Tools/PowerShellCore.script b/Projects/PhoenixPE/Applications/System Tools/PowerShellCore.script index 1f21423..cb61a82 100644 --- a/Projects/PhoenixPE/Applications/System Tools/PowerShellCore.script +++ b/Projects/PhoenixPE/Applications/System Tools/PowerShellCore.script @@ -35,8 +35,8 @@ Author=Homes32 Level=5 Selected=False Mandatory=False -Version=1.0.14.0 -Date=2024-06-20 +Version=1.1.0.0 +Date=2024-06-22 [Variables] %ProgramFolder%="PowerShell" @@ -45,6 +45,7 @@ Date=2024-06-20 %SetupFile%="PowerShell_x86.zip" %DownloadURLx86%=https://github.com/PowerShell/PowerShell/releases/download/v%ProgramVersion%/PowerShell-%ProgramVersion%-win-x86.zip %DownloadURLx64%=https://github.com/PowerShell/PowerShell/releases/download/v%ProgramVersion%/PowerShell-%ProgramVersion%-win-x64.zip +%ConfigFile%="%TargetPrograms%\%ProgramFolder%\powershell.config.json" [Process] Echo,"Processing %ScriptTitle%..." @@ -72,6 +73,9 @@ RegRead,HKLM,"Tmp_System\ControlSet001\Control\Session Manager\Environment","Pat StrFormat,CTrim,%SysPath%,";",%SysPath% RegWrite,HKLM,0x2,"Tmp_System\ControlSet001\Control\Session Manager\Environment","Path","%SysPath%;%PEPrograms%\%ProgramFolder%\;" +// Execution Policy +JSONWrite,%ConfigFile%,"Microsoft\.PowerShell:ExecutionPolicy",%cmb_ExecutionPolicy% + RegUnloadHives /////////////////////////////////////////////////////////////////////////////////// @@ -134,13 +138,13 @@ DirDeleteEx,"%ProgramsCache%\%ProgramFolder%" [SetDefaultOptions] System,Cursor,Wait WriteInterface,Value,%ScriptFile%,Interface,cb_RunFromRam,False -WriteInterface,Value,%ScriptFile%,Interface,cb_AlwaysDownload,False WriteInterface,Value,%ScriptFile%,Interface,cb_DesktopShc,False WriteInterface,Value,%ScriptFile%,Interface,cb_StartMenuShc,True WriteInterface,Value,%ScriptFile%,Interface,cb_PinToTaskbar,False WriteInterface,Value,%ScriptFile%,Interface,cb_PinToStartMenu,False WriteInterface,Value,%ScriptFile%,Interface,txt_StartMenuFolder,"System Tools" WriteInterface,Value,%ScriptFile%,Interface,txt_ShortcutName,"PowerShell" +WriteInterface,Value,%ScriptFile%,Interface,cmb_ExecutionPolicy,"RemoteSigned" System,Cursor,Normal [#ToggleAdvancedOptions#] @@ -199,6 +203,9 @@ cb_PinToTaskbar="Pin to Taskbar",1,3,12,142,122,18,False cb_PinToStartMenu="Pin to Start Menu",1,3,12,161,122,18,False txt_StartMenuFolder="Start Menu folder:",1,0,12,201,119,21,"System Tools" txt_ShortcutName="Shortcut Name:",1,0,12,243,119,21,PowerShell +bvl_Options=Options,1,12,150,90,197,184,8,Bold +lbl_ExecutionPolicy="Execution Policy",1,1,160,110,150,16,8,Normal +cmb_ExecutionPolicy=RemoteSigned,1,4,160,125,150,21,AllSigned,Bypass,RemoteSigned,Restricted,Unrestricted [InterfaceEncoded] Trash.ico=1150,1212 diff --git a/Projects/PhoenixPE/Components/EventLogging.script b/Projects/PhoenixPE/Components/EventLogging.script index b1085a5..627d01a 100644 --- a/Projects/PhoenixPE/Components/EventLogging.script +++ b/Projects/PhoenixPE/Components/EventLogging.script @@ -191,7 +191,7 @@ cb_PinToStartMenu="Pin to Start Menu",1,3,17,171,122,18,False txt_StartMenuFolder="Start Menu folder:",1,0,17,211,150,21,"Developer Tools" txt_ShortcutName="Shortcut Name:",1,0,17,253,150,21,"Event Viewer" rtf_Notes=EventLogging.rtf,1,6,200,50,427,247 -lbl_RuntimeRequirement="Note: The Windows Event Viewer requires the PhoenixPE > Components > .NET Framework script to be enabled.",1,1,0,310,626,16,8,Bold +lbl_RuntimeRequirement="Note: The Windows Event Viewer requires the PhoenixPE > Components > .NET Runtime > .NET Framework script to be enabled.",1,1,0,310,653,16,8,Bold [InterfaceEncoded] SetDefaults_16.png=2475,3404 diff --git a/Projects/PhoenixPE/Components/WindowsPowerShell.script b/Projects/PhoenixPE/Components/WindowsPowerShell.script index a73e2db..c5f0031 100644 --- a/Projects/PhoenixPE/Components/WindowsPowerShell.script +++ b/Projects/PhoenixPE/Components/WindowsPowerShell.script @@ -35,8 +35,8 @@ Author=Homes32 Level=4 Selected=False Mandatory=False -Version=1.0.12.0 -Date=2024-06-03 +Version=1.1.0.0 +Date=2024-06-22 [Variables] %ProgramFolder%="WindowsPowerShell" @@ -57,6 +57,11 @@ RequireFile,\Windows\System32\WindowsPowerShell RegLoadHives +If,Not,%RegistrySoftwareSource%,Equal,"Install.wim",Begin + RegCopy,HKLM,"Tmp_Install_Software\Microsoft\PowerShell",HKLM,"Tmp_Software\Microsoft\PowerShell" + RegCopy,HKLM,"Tmp_Install_Software\Classes,*PowerShell*",HKLM,"Tmp_Software\Classes\",WILDCARD +End + // Register AppPath RegWrite,HKLM,REG_EXPAND_SZ,"Tmp_Software\Microsoft\Windows\CurrentVersion\App Paths\%ProgramExe%","","%SystemRoot%\system32\WindowsPowerShell\v1.0\%ProgramExe%" @@ -64,6 +69,11 @@ RegWrite,HKLM,REG_EXPAND_SZ,"Tmp_Software\Microsoft\Windows\CurrentVersion\App P RegRead,HKLM,"Tmp_System\ControlSet001\Control\Session Manager\Environment","Path",%SysPath% StrFormat,CTrim,%SysPath%,";",%SysPath% RegWrite,HKLM,0x2,"Tmp_System\ControlSet001\Control\Session Manager\Environment","Path","%SysPath%;%SystemRoot%\system32\WindowsPowerShell\v1.0\;" +RegWrite,HKLM,0x2,"Tmp_System\ControlSet001\Control\Session Manager\Environment","PSModulePath","#$pSystemRoot#$p\system32\WindowsPowerShell\v1.0\Modules\" + +// Execution Policy +RegWrite,HKLM,0x1,"Tmp_Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell","ExecutionPolicy",%cmb_ExecutionPolicy% +If,%SourceArch%,Equal,x64,RegWrite,HKLM,0x1,"Tmp_Software\Wow6432Node\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell","ExecutionPolicy",%cmb_ExecutionPolicy% RegUnloadHives @@ -94,6 +104,7 @@ WriteInterface,Value,%ScriptFile%,Interface,cb_PinToTaskbar,False WriteInterface,Value,%ScriptFile%,Interface,cb_PinToStartMenu,False WriteInterface,Value,%ScriptFile%,Interface,txt_StartMenuFolder,"System Tools" WriteInterface,Value,%ScriptFile%,Interface,txt_ShortcutName,"Windows PowerShell" +WriteInterface,Value,%ScriptFile%,Interface,cmb_ExecutionPolicy,"Unrestricted" System,Cursor,Normal [#ToggleAdvancedOptions#] @@ -136,18 +147,20 @@ Message,"Windows PowerShell is an automation and configuration tool/framework in // Related........: // =============================================================================================================================== [Interface] -//bvl_Homepage=bvl_Homepage,1,12,367,5,72,25 -//web_Homepage=Homepage,1,10,377,9,60,18,https:// btn_SetDefaultOptions=,1,8,541,5,25,25,SetDefaultOptions,SetDefaults_16.png,True,"__Restore Defaults" btn_AdvancedOptions=,1,8,571,5,25,25,ToggleAdvancedOptions,Advanced_Disabled_16.png,True,"__Show Advanced Options" btn_ScriptInfo=,1,8,601,5,25,25,ShowScriptInfo,Help_16.png,True,"__Script Info" -bvl_Shortcuts=Shortcuts,1,12,5,90,133,184,8,Bold -cb_DesktopShc=Desktop,1,3,12,104,122,18,False -cb_StartMenuShc="Start Menu",1,3,12,123,122,18,True -cb_PinToTaskbar="Pin to Taskbar",1,3,12,142,122,18,False -cb_PinToStartMenu="Pin to Start Menu",1,3,12,161,122,18,False -txt_StartMenuFolder="Start Menu folder:",1,0,12,201,119,21,"System Tools" -txt_ShortcutName="Shortcut Name:",1,0,12,243,119,21,"Windows PowerShell" +bvl_Shortcuts=Shortcuts,1,12,5,50,133,184,8,Bold +cb_DesktopShc=Desktop,1,3,12,64,122,18,False +cb_StartMenuShc="Start Menu",1,3,12,83,122,18,True +cb_PinToTaskbar="Pin to Taskbar",1,3,12,102,122,18,False +cb_PinToStartMenu="Pin to Start Menu",1,3,12,121,122,18,False +txt_StartMenuFolder="Start Menu folder:",1,0,12,161,119,21,"System Tools" +txt_ShortcutName="Shortcut Name:",1,0,12,203,119,21,"Windows PowerShell" +bvl_Options=Options,1,12,150,50,197,184,8,Bold +lbl_ExecutionPolicy="Execution Policy",1,1,160,70,150,16,8,Normal +cmb_ExecutionPolicy=Unrestricted,1,4,160,85,150,21,AllSigned,Bypass,RemoteSigned,Restricted,Unrestricted +lbl_RuntimeRequirement="Note: Requires the PhoenixPE > Components > .NET Runtime > .NET Framework script to be enabled.",1,1,0,310,626,16,8,Bold [InterfaceEncoded] SetDefaults_16.png=2475,3404