0

Im a standard user without admin privileges on my windows 7 box. I wrote a powershell script that doesn't require admin privileges (it downloads data from yahoo finance and saves it as a CSV file):

$client = New-Object System.Net.WebClient
$yf_url = "http://download.finance.yahoo.com/d/quotes.csv?s=EDV,BND&f=sl1d1t1c1ohgv&e=.csv"
$yf_file = "prices.csv"
$client.DownloadFile($yf_url, $yf_file)

From Get-ExecutionPolicy I know that the security policy on my system is set to Restricted (the default), but Im wondering if there is a way to run this script without having admin privileges.

If I write a powershell script locally that doesnt require admin privileges, is there a way to set the execution policy so I can run it, without having to elevate myself to admin (which I cant do because its a work computer)?

when i runt he script with Invoke-Expression get_prices.ps1 in the folder D:\myfiles (D: is a second hard drive) I get the error message:

File D:\myfiles\get_prices.ps1 cannot be loaded because the execution of scripts is disabled on your system

  • what folder are you downloading to? you should be able to execute a script as a normal user if that script doesn't do anything that requires admin. do you have full control of the destination directory? – Frank Thomas Jun 4 '14 at 16:03
  • @FrankThomas yes I do. I'm downloading to the local folder which right now is simply D:\myfiles\prices.csv (D: is a second hard drive). I added part of the error message (cant copy/paste from powershell but ill type the rest in in a bit) – Michael A Jun 4 '14 at 16:03
2

Try running the script like this from the Run prompt or a Shortcut:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File D:\myfiles\get_prices.ps1
  • That works! Apparently I just need to specify the full file path for the prices.csv file. it must have been trying to write it somewhere that requird admin privileges. – Michael A Jun 4 '14 at 16:48
  • It's not an issue of admin privileges. Running powershell.exe gives you access to switches like -ExecutionPolicy, which bypasses the computer's execution policy long enough to execute that script. – Tim Ferrill Jun 4 '14 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.