When I start a script with "Run with Powershell" its starting slow. First it is searching for avaiable modules and after this its asking for a Execution Policy Change. Is there a way to suspend them?
Thanks for the help!
When I start a script with "Run with Powershell" its starting slow. First it is searching for avaiable modules and after this its asking for a Execution Policy Change. Is there a way to suspend them?
Thanks for the help!
Sure but understand the consequences
Set-ExecutionPolicy Unrestricted –Forc
Starting with version 3, Powershell does module autoloading, which you can disable by adding this line to your Powershell script (or profile):
$PSModuleAutoloadingPreference = “none”
Be careful, though, as this means that any cmdlet/function that's not part of the default modules Powershell loads at startup will not be available.
As an indication, I launched (get-command).count
both with and without that line:
Module autoloading on: 1753
Module autoloading off: 213
If you need to load more modules, you can simply add Import-module
instructions in your script.
As for the execution policy, you can also force it when launching powershell:
powershell -executionpolicy unrestricted <path to your script>
As was mentioned earlier, be careful with this parameter, as it will enable launching any Powershell script on your system. As long as you're in control of what scripts you're launching, there's nothing to be worried about.