Powershell scripts in Windows 2012R2 not running

痴心易碎 提交于 2019-12-11 23:51:20

问题


I just migrated my powershell scripts from 2003 to 2012R2 server.

But when I try and run my powershell scripts it gives me foll errors:

I cant set time, I cant set date, I cant access some files,I cant run scheduled tasks from the script. It keeps giving me access is denied error.

However when I right click on powershell and run as administrator it works fine.

I am confused as I have all the admin rights on the PC and I have set my powershell execution policy as unrestricted as well.

Any Help is welcome.Thanks!


回答1:


You need to run PowerShell as an admin to make changes to your system, as user3325210 said.

Server 2003 didn't have UAC, so if you were an admin, you were always running as an admin. With the introduction of UAC, even if you do have administrative rights on a machine, everything in Windows launches safe. That is, if you want to make changes on your system through an app, be it through PowerShell or Command prompt, you'll need to launch PowerShell as an administrator.

This means right-clicking PowerShell and clicking 'Run as Administrator', like so,

Now, if you're trying to do this through a scheduled task as you mentioned, then you need to make use of the option to launch the process as an admin, it is listed as 'Run with Highest Privileges'

Just make sure that you are using an account that has admin rights on the system you're setting up this Task.



来源:https://stackoverflow.com/questions/29101543/powershell-scripts-in-windows-2012r2-not-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!