Add registry key

I have to run this command remotely:
set-ItemProperty-Path 'hklm: \ \ SOFTWARE \ Microsoft \ PowerShell \ 1 \ ShellIds \ Microsoft.PowerShell '-Name “ExecutionPolicy”-Value “RemoteSigned”
It only works if I manually start Powershell in “Run as Administrator”
you can run it automatically?
I used this command:

$args = @’
powershell.exe -Command {
set-ItemProperty -Path 'hklm:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' -Name “ExecutionPolicy” -Value “RemoteSigned”
}
'@
Start-Process -ArgumentList $args -Verb RunAs PowerShell

I get the following error: “The execution of scripts is disabled on your system”
I would just bypass this restriction …

Jacko, please see example of running remote commands in the post https://powershell.org/forums/topic/powershell-ruan-as-administrator/

The problem is that I would like to overcome the error “” The execution of scripts is disabled on your system. "
It only works if I start, first and manually, Powershell in “run as administrator”
I would like to start running the script automatically without any manual intervention and to do this I need to be able to write the key “ExecutionPolicy” in the registry …
I hope I have explained the problem in an understandable way…

I think you don’t need to modify the registry value directly.

Two easy options:

  1. Use a Group Policy to set the PowerShell execution policy for all machines.
  2. Invoke-Command -ComputerName client1, client2 -ScriptBlock { Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force }

Best,
Daniel

Unfortunately PCs are in remote locations and not on the same LAN.
The first method can be applied using a script?
The method 2 is applicable on PCs that are outside the LAN?
They are not in the domain and the operators have little computer experience …
So I wanted to create a script that should only be performed by the operator …

In this way it works:
Set-ExecutionPolicy RemoteSigned –Scope CurrentUser -Force

$args = @’
powershell.exe -Command {
set-ItemProperty -Path 'hklm:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' -Name “ExecutionPolicy” -Value “RemoteSigned”
}
'@
Start-Process -ArgumentList $args -Verb RunAs PowerShell

(thanks to the suggestion by Alexander Johansson)
How can I run the command Set-ExecutionPolicy RemoteSigned –Scope CurrentUser -Force automatically without opening the powershell shell and run the command manually?