2

When trying to run Set-Date in my powershell script it fails because it claims to require more permissions. I have added the groups Users and even Everyone to the Adjust system time Local Security Policy. Of course I could run it elevated to admin, but I'm trying to avoid that. What's extra odd is that this script has worked fine so far on some machines.

Powershell version is 5.1, windows version is 10 Enterprise 2016 (v1607)

The error message:

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
Henrik Erstad
  • 681
  • 3
  • 11
  • 21
  • Could be that setting the system time is blocked for standard users in group policy. I would double check using gpresult – Daniel Jun 06 '21 at 21:14
  • @Daniel thanks, I will definitely check that tomorrow morning. I would check now, but the machine isn't responding to remote desktop. – Henrik Erstad Jun 06 '21 at 21:22
  • @Daniel As far as I can tell, there are no group policies restricting adjusting system time – Henrik Erstad Jun 06 '21 at 21:51
  • @HenrikErstad I cannot reproduce your error on a Windows 10 Pro v1809 (it works as expected). Do you make sure the user that gets permissions to modify the system time creates a **new** logon session **after** you changed the Local Security Policy? – stackprotector Jun 07 '21 at 09:43
  • I cannot reproduce it on my own machine, or even similar machines to the problematic ones. I have rebooted the machines after setting the Local Security Policy – Henrik Erstad Jun 07 '21 at 09:52
  • You should update your question with a copy-and-paste of the _exact_ error message (not a screen shot). – Bill_Stewart Jun 07 '21 at 18:55
  • @Bill_Stewart I didn't do that initially as it's in Norwegian, but I'll add it anyway :) – Henrik Erstad Jun 08 '21 at 06:37

1 Answers1

0

Though I do not fully understand why, it works when you disable the policy User Account Control: Run all administrators in Admin Approval Mode.

Henrik Erstad
  • 681
  • 3
  • 11
  • 21