简体   繁体   English

Windows 2012R2中的Powershell脚本未运行

[英]Powershell scripts in Windows 2012R2 not running

I just migrated my powershell scripts from 2003 to 2012R2 server. 我只是将Powershell脚本从2003迁移到2012R2服务器。

But when I try and run my powershell scripts it gives me foll errors: 但是,当我尝试运行Powershell脚本时,会出现以下错误:

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. 但是,当我右键单击powershell并以管理员身份运行时,它可以正常工作。

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. 我很困惑,因为我拥有PC上的所有管理员权限,并且我将Powershell执行策略也设置为不受限制。

Any Help is welcome.Thanks! 欢迎任何帮助。谢谢!

You need to run PowerShell as an admin to make changes to your system, as user3325210 said. 如user3325210所述,您需要以管理员身份运行PowerShell才能对系统进行更改。

Server 2003 didn't have UAC, so if you were an admin, you were always running as an admin. Server 2003没有UAC,因此,如果您是管理员,则始终以管理员身份运行。 With the introduction of UAC, even if you do have administrative rights on a machine, everything in Windows launches safe. 随着UAC的引入,即使您确实拥有计算机的管理权限,Windows中的所有内容也可以安全启动。 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. 也就是说,如果您想通过应用程序在系统上进行更改(通过PowerShell或Command提示符进行更改),则需要以管理员身份启动PowerShell。

This means right-clicking PowerShell and clicking 'Run as Administrator', like so, 这意味着右键单击PowerShell,然后单击“以管理员身份运行”,就像这样,

一次以管理员身份运行流程

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' 现在,如果您尝试通过提到的计划任务来执行此操作,那么您需要利用该选项以管理员身份启动进程,该进程被列为“以最高特权运行”

选中此框可在计划任务期间以管理员身份运行PowerShell进程

Just make sure that you are using an account that has admin rights on the system you're setting up this Task. 只需确保您使用的帐户在设置此任务的系统上具有管理员权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Packer - Windows Server 2012R2 - 安装PowerShell 5 - Packer - Windows Server 2012R2 - Install PowerShell 5 使用powershell禁用自动更新(2012R2) - Disable automatic updates (2012R2) with powershell Windows Server 2012R2 Core - 无法运行 powershell DSC - Windows Server 2012R2 Core - can't run powershell DSC 通过Chef在Windows Server 2012r2上解压缩文件 - Unzipping a file on windows server 2012r2 via chef 从FSRM任务运行时出现AD RMS PowerShell错误-2012R2 - AD RMS PowerShell errors when run from FSRM Tasks - 2012R2 Windows Server 2012 - 从 C# 运行 powershell 脚本时拒绝访问注册表 - Windows Server 2012 - Access to registry denied when running powershell scripts from C# Windows 2012 R2 cmdlet 不在 Windows 2012 R2 上运行 - windows 2012 R2 cmdlet not running on windows 2012 R2 有没有办法在 Windows 10 或 Server 2012r2 中递归复制包含特定字符串的文件,同时保持文件夹结构? - is there a way to recursively copy files in Windows 10 or Server 2012r2 which contain a particular string while maintaining the folder structure? Windows 2012 R2中的Powershell 5.1 - Powershell 5.1 in Windows 2012 R2 为什么我在 Windows Server 2012 r2 上的 PowerShell ISE 中运行 Get-WindowsCapability 时出现错误? - Why do I get an error running Get-WindowsCapability in PowerShell ISE on Windows Server 2012 r2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM