Powershell – Associate .ps1 to powershell.exe through domain GPO on 2008r2

extensionfile-associationsgroup-policypowershellwindows-server-2008-r2

I need to associate .ps1 with powershell.exe instead of Notepad via GPO from a 2008r2 DC. I've seen one question mention CSE under Computer Configuration\Preferences\Control Panel Settings\Folder Options and setting it there. But I'm not sure exactly what to do and I can't find anything helpful anywhere.

Best Answer

You're close. Under Folder Options, Right Click in the main part of the area and go to New -> File Type

Action: Create
File extension: .ps1
Check Configure Class Settings
Under Action -> New
Action: Open
Application: *Path to Powershell*

Then OK/Save out.

Reference: TechNet: Configure a File Type Item

EDIT: Can't find the class, and I even used PowerShell to extract that dropdown list and search it...nothing.

There is a way to set it via Registry in Group Policy. The class is Microsoft.PowerShellScript.1 and full path to it is:

HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command

Change the (Default) value to:

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-file" "%1"

This is found in the GPOE:

\Computer Configuration\Preferences\Windows Settings\Registry

SUMMARY: Create a new Registry Item:

Settings:
  Action: Update
  Hive: HKEY_CLASSES_ROOT
  Key Path: Microsoft.PowerShellScript.1\Shell\Open\Command
  Value name: Check Default
  Value type: REG_SZ
  Value data: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-file" "%1"

Then wait for GP flush on machines.