1

I have a Power Shell script file (it's PS5 on Win10) that allow me to change to a specific wallpaper when I execute it. I can only do that if I have administrator access. There are ways work around like making a .bat file

powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "C:\Users\name\wallp1.ps1"

But it seems that method will change execution policy permanently to unrestricted which is really unsecure What I want is to be able to execute a PS script through Task Scheduler (it must be through that not through Startup folder). I want to be able to change Wallpaper on a specific time and only Task Scheduler can do that. Unless I can do that with command or batch files.

In short: I want to run a PS script through another file without messing with current Execution Policy

Other method seems not work: how to run PowerShell Script when computer starts?

Or maybe there is a way to be able to revert back to default execution policy after the PS script has ran? It must be done automatically in one file

Community
  • 1
  • 1
deXterlab97
  • 135
  • 8
  • Hi, _But it seems that method will change execution policy permanently to unrestricted_ I don't believe so. – sodawillow Feb 09 '17 at 21:49

1 Answers1

2

Using the launch command you provided does not change the execution policy permanently on the host. Tested on Win10 with PS5.

Second most upvoted powershell question on SO

Community
  • 1
  • 1
sodawillow
  • 12,497
  • 4
  • 34
  • 44
  • but every time I open up PowerShell both regular and as admin and type get-executionploicy -list it always lists as unrestricted – deXterlab97 Feb 09 '17 at 23:22
  • Well, your command temporarily sets it to `Bypass`. Try permanently setting it to `RemoteSigned`, for instance (as admin), and then use your shortcut again. – sodawillow Feb 09 '17 at 23:24
  • I thought Remote signed only allow scripts that are signed to execute? – deXterlab97 Feb 10 '17 at 00:50
  • Thanks for the help, it seems there was something wrong with my laptop. Desktop returned RemoteSigned as usual – deXterlab97 Feb 10 '17 at 02:32