0

I want execute following command without opening admin PowerShell prompt.It should be execute on normal prompt. like we are sudo useradd <username> in Linux.

Enable-PSRemoting; 
Set-Item wsman:\\localhost\\client\\trustedhosts $hostIP -Force;
Restart-Service WinRM

I am going integrate this code into C#. Please help me to solve this issue.

0

2 Answers 2

2

What you're asking is not possible directly from a PowerShell script, at least as far as I know. What you can do is create a scheduled task running that script with admin privileges, and then invoke the scheduled task as a normal user.

Sign up to request clarification or add additional context in comments.

Comments

1

That is not possible. Allowing that would be a major security issue in Windows.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.