How can I do to enable and disable WinRM (Window Remote Management)

Trần Ngọc Nam 35 Reputation points
2023-02-24T02:27:17.1233333+00:00

I try enable WinRM with tool psexec: https://learn.microsoft.com/en-us/sysinternals/downloads/psexec

psexec.exe \\Computer-name -s powershell Enable-PSRemoting -Force

And status of service WinRM is runningUser's image

But I can stop it with:

psexec.exe \Computer-name -s powershell Disable-PSRemoting -Force

Pls, give me some advice to stop it.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Limitless Technology 44,751 Reputation points
    2023-02-24T13:56:02.11+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query

    How do I turn off remote management in WinRM?

    Set Microsoft-Windows-Web-Services-for-Management-CoreEnableServerremoteManagement to False to deactivate Server Manager remote management by default on all servers to which you wish to apply the response file. This option prevents remote management throughout the operating system installation procedure.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. XinGuo-MSFT 22,231 Reputation points
    2023-02-27T07:24:55.44+00:00

    Hi,

    psexec.exe \Computer-name -s powershell Disable-PSRemoting -Force

    psexec \\computerName powershell -Command "Enable-PSRemoting -Force"  
    psexec \\computerName powershell -Command "Disable-PSRemoting -Force"
    
    

    The psexe can be launched with -d option if it are to be launched in the batch processing on the many computers.


  4. XinGuo-MSFT 22,231 Reputation points
    2023-02-28T06:49:00.03+00:00

    Hi,

    Yes, after running "Disable-PSRemoting -Force", it is no longer possible to establish remote PowerShell connections.

    PS C:\Users\Administrator.AP> Disable-PSRemoting -Force
    WARNING: Disabling the session configurations does not undo all the changes made by the Enable-PSRemoting or
    Enable-PSSessionConfiguration cmdlet. You might have to manually undo the changes by following these steps:
        1. Stop and disable the WinRM service.
        2. Delete the listener that accepts requests on any IP address.
        3. Disable the firewall exceptions for WS-Management communications.
        4. Restore the value of the LocalAccountTokenFilterPolicy to 0, which restricts remote access to members of the Administrators group on the computer.
    

    The warning messages you see after executing Disable-PSRemoting indicate you should take a few more steps to disable PowerShell remoting. However, these steps only add extra security.

    If we want to stop and disable the WinRM service for security reasons, we could use PowerShell:

    Stop-Service WinRM -PassThru
    Set-Service WinRM -StartupType Disabled -PassThru
    

    The -PassThru parameter lets us see the result of the command.


  5. Trần Ngọc Nam 35 Reputation points
    2023-03-02T09:03:43.67+00:00

    Oh sorry, I mean stop WinRM service.

    So, when I stop PSRemoting, WinRM service is still running.

    I used GPO to enable/disable WinRM services.

    Thank you for your advice

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.