由于权限,在 Powershell 脚本中使用 Set-Date 失败
Using Set-Date in a Powershell script fails due to permissions
在我的 powershell 脚本中尝试 运行 Set-Date
时失败,因为它声称需要更多权限。我已将用户组甚至每个人添加到调整系统时间本地安全策略中。我当然可以 运行 将其提升为管理员,但我正在努力避免这种情况。更奇怪的是,这个脚本到目前为止在某些机器上运行良好。
Powershell 版本为 5.1,windows 版本为 10 Enterprise 2016 (v1607)
错误信息:
PS > Set-Date "2021-06-07T10:00"
Set-Date : Klienten har ikke nødvendig tilgangsnivå
At line:1 char:1
+ Set-Date "2021-06-07T10:00"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-Date], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand
虽然我不完全明白为什么,当你禁用策略时它会起作用 User Account Control: Run all administrators in Admin Approval Mode
。
在我的 powershell 脚本中尝试 运行 Set-Date
时失败,因为它声称需要更多权限。我已将用户组甚至每个人添加到调整系统时间本地安全策略中。我当然可以 运行 将其提升为管理员,但我正在努力避免这种情况。更奇怪的是,这个脚本到目前为止在某些机器上运行良好。
Powershell 版本为 5.1,windows 版本为 10 Enterprise 2016 (v1607)
错误信息:
PS > Set-Date "2021-06-07T10:00"
Set-Date : Klienten har ikke nødvendig tilgangsnivå
At line:1 char:1
+ Set-Date "2021-06-07T10:00"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-Date], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand
虽然我不完全明白为什么,当你禁用策略时它会起作用 User Account Control: Run all administrators in Admin Approval Mode
。