Why PS2 opens in notepad and not PS1?

Welcome Forums General PowerShell Q&A Why PS2 opens in notepad and not PS1?

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 8 months ago.

  • Author
  • #5321

    Topics: 1562
    Replies: 0
    Points: 0
    Rank: Member

    by vgandhi at 2012-12-04 13:33:39

    We have written a few powershell PS1 scripts and all work fine.
    Now, we are on our way to migrate all of them to PS2 and having trouble in executing new ones.
    When I execute command ./my_script.ps1, it does execute it with no trouble, but ps2 script opens up in notepad by itself for some reason.

    What could be the reason for this? Can some one please help me in resolving this?

    by jaberkenbile at 2012-12-04 15:00:47

    vgandhi: Are your script files using a .ps2 extension?
    If so they need to have a .ps1 extension.
    All versions of PowerShell use .ps1 as the file extension for scripts.

    Please see:


    by RichardSiddaway at 2012-12-05 01:47:48

    By default powershell files – including scripts with a .ps1 extension – will open in notepad if you double click them or right click and select open. This is by design to reduce the cahnces of inadvertantly running a script & remove some of the scenarios in which maicious scripts could be run without your knowledge

The topic ‘Why PS2 opens in notepad and not PS1?’ is closed to new replies.