How can I get the PowerShell ISE to do syntax highlighting on files with a custom extension?

Can't be done because, as of the current version, the ISE determines whether to turn syntax highlighting on or not based on the file name extension: this behavior can't be changed as the recognized extensions are (unfortunately) fixed in the code.

They are, of course:

  • .ps1
  • .psm1
  • .psd1

For those who are wondering, the ISE determines this within the IsPowerShellSourceCodeFile internal property of the Microsoft.PowerShell.Host.ISE.ISEFile type, exported by the Microsoft.PowerShell.GPowerShell assembly. And no, reflection does not allow to cheat it, as trying to inject one of the supported extensions into the Extension property causes the ISE to crash.