Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

PowerShell Configuration for External Data Files

As mentioned in the "Documents" section, "PowerShell environment setup", by default PowerShell is configured not to run any scripts. You will need to enable script execution on PowerShell.

The documentation recommends changing the ExecutionPolicy from "Restricted" to "Unrestricted". In my testing I have no issues running the scripts with ExecutionPolicy set to RemoteSigned. This allows for retention of some of PowerShell's security.

Changing the ExecutionPolicy requires having Administrative rights on the local computer. What if you do not have administrative rights or you do not want to change the ExecutionPolicy - maybe it's a shared computer or a work computer. Is there a way to still run the scripts for the external files? Yes.

On my computer, if I open a regular command prompt (do not use run as administrator) and enter PowerShell I receive an error stating running scripts is disabled on this system. But I still get the PS C:\Users\[user_name]> prompt. If I enter Get-ExecutionPolicy -list | Format-Table -AutoSize I'm presented with the following list:

MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Restricted

Here's how to get around this restriction. Edit file UpatePSData.bat and enter -ExecutionPolicy Bypass on each line between powershell and .\Scripts.... Your new file should resemble the one below.

echo off
powershell -ExecutionPolicy Bypass .\Scripts\GetQuotesYahoo.ps1
powershell -ExecutionPolicy Bypass .\Scripts\GetQuotesGoogle.ps1
powershell -ExecutionPolicy Bypass .\Scripts\GetQuotesGoogleWeb.ps1
powershell -ExecutionPolicy Bypass .\Scripts\GetExchRatesBoC.ps1
powershell -ExecutionPolicy Bypass .\Scripts\GetDividendsYahoo.ps1
powershell -ExecutionPolicy Bypass .\Scripts\GetQuotesAriva.ps1
powershell -ExecutionPolicy Bypass .\Scripts\GetQuotesYahooIntraday.ps1
powershell -ExecutionPolicy Bypass .\Scripts\GetExchRatesYahooIntraday.ps1
powershell -ExecutionPolicy Bypass .\Scripts\ArchiveOldQuotes.ps1
powershell -ExecutionPolicy Bypass .\Scripts\MakePSDataFiles.ps1
powershell -ExecutionPolicy Bypass .\Scripts\CreateDatesFile.ps1
powershell -ExecutionPolicy Bypass .\Scripts\AppendGeneratedQuotes.ps1
powershell -ExecutionPolicy Bypass .\Scripts\CheckPSFiles.ps1
choice /C Y /T 10 /D Y /M "Waiting 10sec before closing"


Comments

  • Hi Smith,

    Thank you!!!! This is great, I much more would prefer if there is no need to change Execution Policy at computer level. I am reconfigured my machine to bypass execution policy for specific script - I'll run it for few weeks and if there are no problems, next version will use your suggestions.

    Thank you again, this is great suggestion - I was not aware about this option before.
  • Hi Smith,
    I like this concept. I'll be trying it on my PS Configuration. Thanks for sharing
Sign In or Register to comment.