Windows 10 default file association (.ps1 > Powershell)

samiam41 used Ask the Experts™
Hey Experts.  Running into a situation that is just defying logic, so I know it's time to bring in the pro's.

This is on a Windows 10 ENT test box.  Using a GP, I'm deploying a defaultapps.xml file for many of the apps we have on that Win 10 PC and for all but one file association, the file associations match the defaultapps.xml.

The one that isn't getting set is with .ps1.  Here is the code that I am using in that xml file for Powershell:

<Association Identifier=".ps1" ProgId="Applications\powershell.exe" ApplicationName="Windows PowerShell" />

Open in new window

When I run gpupdate /force on that PC, it runs successfully.  I use cmd /c assoc .ps1 to see if .ps1 is associated with PowerShell and it shows it is.  When I go to Default Apps > file extension, .ps1 shows Notepad.  However when I browse to a directory where there are .ps1 files, the icon next to a powershell script has the notepad icon and if I open it, the script opens with Notepad.

I'm at a loss for trying to get .ps1 files to open with PowerShell.  Can anyone offer any insight into this?  I would appreciate your help and time.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Can't offer any insights as to why this fails, sorry, but maybe a workaround using Group Policy Preferences.
Add, modify and delete Registry keys using Group Policy
This is for a "User Configuration" policy; if you want to apply it as "Computer Configuration" for all users at once, just change the hive to HKEY_LOCAL_MACHINE. Per user has the advantage that the default setting (which is in the HKLM hive) won't be overwritten.
For testing, you can add the key manually to the registry as indicated; changes apply immediately.
Action: Update
Key Path: Software\Classes\Microsoft.PowerShellScript.1\Shell\Open\Command
Default: <Checked>
Value type: REG_SZ
Value data: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoExit -File "%1"

Open in new window

If you want to keep the PS console open after the script has run, add the -NoExit argument before -File.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial