Make Powershell scripts run from a Powershell Window
It is no wonder that powershell never caught on like bash, python or even Perl. You can’t share and easily run them as Microsoft defaults the setting to only allow you to run signed script. Signing Powershell scripts is a major waste of time and energy.
Running a command like the following works for only one session,
set-executionpolicy remotesigned Process -Force
Use Windows Policy editor and Registry editor
So, you need to edit the registry to convince the Windows System to really allow you to run script as you might on Linux. However, Micorsoft has even blocked this with Computer policy. So first you must allow scripts to even run.
To allow your system to run, First run
Now go into
Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell. Click on the “Turn on Script Execution”
Change it from “not configured” to Enabled, then select the execution policy that you prefer. I will select Allow Local Scripts and press OK.
If you run get-executionpolicy, you will now see: that RemoteSigned is enables instead of Restricted
But still you will get that retarded Windows response forbidding you from running your script
cannot be loaded. The file XXXXX is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1 + .\XXXXX.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) , PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
Open PowerShell as Administrator
Now, as Windows Administrator, you can edit the registry with the following command:
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\PowerShell -Name ExecutionPolicy -Value ByPass
Finally you should be able to run your Powershell script from the command like Unix / Linux folks have been doing for decades.
You must log in to post a comment.