Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Create a Script to Enable WinRM on a Remote Computer

Script:


# Define the remote computer name
$remoteComputer = "RemoteComputerName"

# Create a session to the remote computer
$session = New-PSSession -ComputerName $remoteComputer

# Enable WinRM service on the remote computer
Invoke-Command -Session $session -ScriptBlock {
# Enable the WinRM service
Enable-PSRemoting -Force

# Set the WinRM service to start automatically
Set-Service -Name "WinRM" -StartupType Automatic

# Start the WinRM service
Start-Service -Name "WinRM"
}

# Close the session
Remove-PSSession -Session $session

Write-Host "WinRM has been enabled on the remote computer: $remoteComputer"

How to Run the Script:


1. Open PowerShell on your local machine with administrative privileges.
2. Copy the script above and paste it into a new PowerShell script file, e.g., Enable-WinRM.ps1.
3. Replace "RemoteComputerName" with the actual name or IP address of the remote computer you want to configure.
4. Save the script file.
5. Execute the script by running .\Enable-WinRM.ps1 in your PowerShell window.
6. Ensure that you have the necessary permissions and network access to the remote computer.
7. After execution, the script will enable WinRM on the specified remote computer, allowing for remote management.


To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.