2

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.

Holocryptic
  • 5,665
  • 2
  • 28
  • 37

1 Answers1

4

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.

Theo
  • 989
  • 5
  • 11