So I am running a basic script to copy a shortcut to the public profile desktop so that any user who logs in will have that on their desktop. The circumstances are that I will have to bypass execution policies, so I am doing this via batch file. This is what I have tried but it doesnt seem to work for me...
Powershell.exe -Command "& {Start-Process Powershell.exe -ArgumentList 'ExecutionPolicy Bypass -File DesktopShortcut.ps1' -Verb RunAs}"
and the PS file is simply:
Copy-Item -Path "aiStarter.lnk" -Destination "C:\Users\Public\Desktop\" -PassThru
When I run it the window just flashes then disappears. If I run it without RunAs I get access denied. I hate to ask this because I'm sure it has been asked before but I am pretty sure I am executing this correctly. Thoughts?
powershell.exedoesn't have a "runas" switch, so you need to leverage theStart-Processcmdlet.-ExecutionPolicyin the argument list, notExecutionPolicy(without leading hyphen). However, I agree with @Bill_Stewart that group policy (preferences) is a better way to do what you want.