Windows 2012R2中的Powershell脚本未运行 [英] Powershell scripts in Windows 2012R2 not running

查看:374
本文介绍了Windows 2012R2中的Powershell脚本未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将Powershell脚本从2003迁移到2012R2服务器.

但是,当我尝试运行Powershell脚本时,会出现以下错误:

我无法设置时间,无法设置日期,无法访问某些文件,无法从脚本运行计划的任务.它不断给我访问被拒绝的错误.

但是,当我右键单击Powershell并以管理员身份运行时,它运行正常.

我很困惑,因为我拥有PC上的所有管理员权限,并且我也将Powershell执行策略设置为不受限制.

欢迎任何帮助.谢谢!

解决方案

正如user3325210所说,您需要以管理员身份运行PowerShell才能对系统进行更改.

Server 2003没有UAC,因此,如果您是管理员,则始终以管理员身份运行.随着UAC的引入,即使您确实拥有计算机的管理权限,Windows中的所有内容也可以安全启动.也就是说,如果要通过应用程序在系统上进行更改,无论是通过PowerShell还是Command提示符,都需要以管理员身份启动PowerShell.

这意味着右键单击PowerShell,然后单击以管理员身份运行",

现在,如果您尝试通过提到的计划任务来执行此操作,那么您需要利用该选项以管理员身份启动进程,该进程将列为以最高特权运行"

只需确保您使用的帐户在设置此任务的系统上具有管理员权限.

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!

解决方案

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.

这篇关于Windows 2012R2中的Powershell脚本未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆