Run Powershell Scripts in Notepad++

Lai, Shi Peng 0 Reputation points
2023-05-11T20:02:20.7433333+00:00

Hi,

I would like to execute/run PowerShell Scripts from Notepad++

See article below,

https://itecnote.com/tecnote/r-how-to-execute-a-powershell-script-from-notepad/

Is this something that can be achieved ? Or it's not supported....

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,308 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Rich Matheisen 45,831 Reputation points
    2023-05-12T01:53:56.2033333+00:00

    @Dannelly Jr, Robert B Those videos were originally on Microsofts' "Channel9". They're still relevant, but also out of date (beside being overly long because of the back-and-forth between the presenters).

    This is more up-to-date (but still not to PS 5) and you can move at your own pace: https://www.sapien.com/books_training/Windows-PowerShell-4

    0 comments No comments

  2. CrackerJack 0 Reputation points
    2023-07-24T22:13:13.8333333+00:00

    To answer the question, for anyone looking.

    pwsh "$(FULL_CURRENT_PATH)"

    0 comments No comments

  3. Laird Mark D. MacLachlan 11 Reputation points
    2023-10-12T22:58:34.7066667+00:00

    I would like to jump in and say I fully understand why you might want to execute a script from within NotePad++.

    For anyone advocating using PowerShell_ISE which is installed on all servers by default I agree it is the simplest solution, however there are drawbacks to doing so. There is a known bug that will cause the ISE to lock up if your script creates a GUI form. I have seen this bug activate when using code to create login prompts for MSGraphAPI. Microsoft has ignored this bug and is directing us to use VS Code. The issue with that is that it is a larger install and my company does not want to push that to our servers.

    The security folks at my company advocate switching to PWSH, and some modules such as PNP.PowerShell are making the move to PowerShell 7+. The issue with that is that not everything supports it. For example we use Atlassian Bamboo to schedule jobs. Bamboo only supports running script files for PowerShell.exe not PWSH.exe. While I certainly could create a bamboo job to launch PWSH.exe and pass it a script name, that would result in the Bamboo logs only showing me errors in launching the script and not the script log that I would otherwise get.

    Microsoft was wise to allow multiple versions of PowerShell to exist on the same machine, however I feel like they made our lives very difficult by not making all versions execute from the same executable name. There is no reason I can understand why they could not replace PowerShell.exe to launch PowerShell files of all versions. Then give us an IDE for the different version and have that ship with the base server code.

    0 comments No comments