Is it impossible to run powershell scripts that I wrote locally without admin privileges even if the scripts themselves dont require admin rights?
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
Related videos on Youtube
Michael A
Updated on September 18, 2022Comments
-
Michael A over 1 year
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 toRestricted
(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 folderD:\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
-
Michael A almost 10 years@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 almost 10 yearsThat 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. -
Tim Ferrill almost 10 yearsIt'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.
-
Mak over 4 yearsHow can I execute command directly instead of ps file? $password = ConvertTo-SecureString "password" -AsPlainText -Force; $cred= New-Object System.Management.Automation.PSCredential ("username", $password ); $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri domain/PowerShell -Authentication Kerberos -Credential $cred; Import-PSSession $Session -DisableNameChecking; When i tried it thrown error