Skip to content

Commit

Permalink
Adding changes to the module script
Browse files Browse the repository at this point in the history
Adding changes from the main script to the module directory. The changes related to execution policy restoration at the end.
  • Loading branch information
HotCakeX committed Nov 17, 2023
1 parent 9c3a2e0 commit bc1fad0
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
#>

[string]$CurrentExecutionPolicy = Get-ExecutionPolicy -Scope Process

# Change the execution policy temporarily only for the current PowerShell session
# Unrestricted is more secure than Bypass because if a script is code signed then tampered, you will see an error, but in bypass mode, no code sign tamper detection happens
Set-ExecutionPolicy -ExecutionPolicy 'Unrestricted' -Scope Process -Force
Expand Down Expand Up @@ -2354,6 +2356,9 @@ finally {
# Restore the title of the PowerShell back to what it was prior to running the script/module
$Host.UI.RawUI.WindowTitle = $CurrentPowerShellTitle

# Set the execution policy back to what it was prior to running the script
Set-ExecutionPolicy -ExecutionPolicy "$CurrentExecutionPolicy" -Scope Process -Force

if (Test-IsAdmin) {
# Reverting the PowerShell executables allow listings in Controlled folder access
Get-ChildItem -Path "$PSHOME\*.exe" | ForEach-Object {
Expand Down

0 comments on commit bc1fad0

Please sign in to comment.