Skip to content

Instantly share code, notes, and snippets.

@asheroto
Last active October 30, 2025 01:19
Show Gist options
  • Select an option

  • Save asheroto/de7d4dacee57f8f5bfffaf9f9f9091bc to your computer and use it in GitHub Desktop.

Select an option

Save asheroto/de7d4dacee57f8f5bfffaf9f9f9091bc to your computer and use it in GitHub Desktop.
Add "Run with PowerShell 7" to the context menu of PS1 scripts.

image

Copy the text in the below file into a file named p7.reg, then run the file to merge the registry changes.

Credits go to chaoscreater for the original reg entries.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1]
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell]
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Edit]
"NoSmartScreen"=""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Edit\Command]
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell7]
@="Run with PowerShell 7 as User"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell7\Command]
@="C:\\Program Files\\PowerShell\\7\\pwsh.exe -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell7AsAdmin]
@="Run with PowerShell 7 as Admin"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell7AsAdmin\Command]
@="\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" \"-Command\" \"\"& {Start-Process pwsh.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \\\"%1\\\"' -Verb RunAs}\""
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Windows.PowerShell.Run]
"MUIVerb"=hex(2):40,00,22,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,\
6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,\
00,5c,00,77,00,69,00,6e,00,64,00,6f,00,77,00,73,00,70,00,6f,00,77,00,65,00,\
72,00,73,00,68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,5c,00,70,\
00,6f,00,77,00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,2e,00,65,00,78,00,\
65,00,20,00,22,00,2c,00,2d,00,31,00,30,00,38,00,00,00
@="Run with PowerShell 5"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Windows.PowerShell.Run\Command]
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment