Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :
TheServerGeeks

IT with everything IT

[How To] Open all Ps1 files at once

/

Have you ever wondered how to open multiple or all the PowerShell Scripts at once? then read below. I will show you how to open all the .Ps1 files stored in a folder at once.

Below is the script which opens all the .Ps1 files in PowerShell ISE once you execute it.

$fileDirectory = "./"
$parse_results = New-Object System.Collections.ArrayList;
foreach($file in Get-ChildItem $fileDirectory){PowerShell_ISE $file}

Save this as “AllScripts.Ps1″ file and whenever you want to open all the .Ps1 files and save the PowerShell scripts in the same folder. 

Right click on this file and select open with PowerShell. This will open all the script files in the directory in PowerShell ISE for editing.

In the same directory, Create a new file called “AllScripts.bat”(Name should be same as the AllScripts file). Right click on this .bat file and select edit in notepad and type below lines and save the file.

 @ECHO OFF
PowerShell.exe -Command "& '%~dpn0.ps1'"

Whenever you want to open the scripts, just double click the AllScripts.bat. 

Note: 
For your knowledge, This batch file will open the AllScripts.Ps1 file in PowerShell and the scripts will be opened in the background. 

Microsoft has set Notepad as the default app for PowerShell Scripts for security reasons. Hence, we have to execute the files in the above-given method. Alternatively, you can set the PowerShell as the default app and execute it directly. But that is not a best practice for security reasons.

1 Comments

Leave a Reply to zvodret iluret Cancel reply

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar