Skip to content

WinRM

60 commands

Windows Remote Management from Linux and PowerShell: Enter-PSSession, Invoke-Command and service configuration.

  • WinRM
  • PowerShell
  • remote management

Basic Configuration2

winrm quickconfig

Configures the WinRM service with default settings and enables the firewall exception.

winrm quickconfig -quiet

Configures WinRM non-interactively without prompting for confirmation.

Service Status2

winrm get winrm/config

Retrieves the full current configuration state of both Client and Service components.

Test-WSMan

Tests the local WinRM service to ensure it is responding to requests.

Target Specification3

Test-WSMan -ComputerName 192.168.1.10

Verifies that the WinRM service is accessible and listening on a remote target.

Test-WSMan -ComputerName 192.168.1.10 -Port 5985

Tests WinRM connectivity on a specific HTTP port.

Test-WSMan -ComputerName 192.168.1.10 -Port 5986 -UseSSL

Tests WinRM connectivity over HTTPS using the default secure port.

Listener Configuration3

winrm enumerate winrm/config/listener

Lists all configured WinRM listeners and their specific settings.

winrm create winrm/config/Listener?Address=*+Transport=HTTP

Creates a new listener that accepts HTTP connections on all network interfaces.

winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="server.domain.com";CertificateThumbprint="THUMBPRINT_GOES_HERE"}

Creates a secure HTTPS listener bound to a specific certificate thumbprint.

Link

Client Configuration3

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.10"

Adds a specific IP address to the TrustedHosts list to allow unauthenticated connection establishment.

Link
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force

Configures the client to trust all hosts, often used in lab environments for testing.

Link
Get-Item WSMan:\localhost\Client\TrustedHosts

Displays the current list of trusted hosts configured on the client.

Link

Service Configuration2

winrm set winrm/config/service @{AllowUnencrypted="true"}

Enables the service to accept unencrypted traffic, typically for debugging or legacy support.

Link
winrm set winrm/config/service/auth @{Basic="true"}

Enables Basic authentication on the service, allowing plain text credentials over the connection.

Link

Interactive Session3

Enter-PSSession -ComputerName 192.168.1.10 -Credential (Get-Credential)

Starts an interactive PowerShell session on the remote computer using prompted credentials.

Link
Enter-PSSession -ComputerName 192.168.1.10 -Authentication Negotiate

Connects using Negotiate authentication, which attempts Kerberos and falls back to NTLM.

Link
Enter-PSSession -ComputerName 192.168.1.10 -Authentication Kerberos

Forces Kerberos authentication, requiring correct SPNs and domain trust.

Link

Legacy Execution2

winrs -r:http://192.168.1.10:5985 -u:Admin -p:Pass cmd

Uses the legacy WinRS tool to launch a command prompt on the remote host via HTTP.

Link
winrs -r:https://192.168.1.10:5986 -u:Admin -p:Pass -ssl "ipconfig /all"

Executes a single command remotely over HTTPS using legacy WinRS syntax.

Link

Remote Command Execution3

Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-Process }

Executes a PowerShell script block on the remote machine and returns objects to the local session.

Link
Invoke-Command -ComputerName 192.168.1.10 -FilePath .\script.ps1

Reads a local PowerShell script file and executes its contents on the remote system.

Link
Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { param($p) Write-Host $p } -ArgumentList "Hello"

Passes local arguments into the remote script block for dynamic execution.

Link

Session Management6

$s = New-PSSession -ComputerName 192.168.1.10 -Credential (Get-Credential)

Creates a persistent PowerShell session object stored in a variable for reuse.

Link
Invoke-Command -Session $s -ScriptBlock { hostname }

Executes a command inside an existing persistent session without re-authenticating.

Link
Get-PSSession

Lists all active PowerShell sessions maintained by the local client.

Link
Remove-PSSession -Session $s

Closes the specified persistent session and frees resources.

Link
Disconnect-PSSession -Id 1

Disconnects a session but leaves it running on the remote host for later reconnection.

Link
Connect-PSSession -ComputerName 192.168.1.10 -Id 1

Reconnects to a previously disconnected session on a remote machine.

Link

File Transfer2

Copy-Item -Path .\tool.exe -Destination C:\Temp\ -ToSession $s

Uploads a local file to the remote system using an existing WinRM session.

Link
Copy-Item -Path C:\Logs\remote.log -Destination .\ -FromSession $s

Downloads a file from the remote system to the local machine via WinRM.

Link

Lateral Movement2

Invoke-Command -ComputerName 192.168.1.10 -Authentication Credssp -Credential (Get-Credential) -ScriptBlock { Get-Service }

Uses CredSSP authentication to allow the remote host to delegate the user's credentials to a second hop.

Link
Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File C:\payload.ps1' }

Remotely triggers a payload execution using Start-Process to detach from the WinRM shell.

Link

Red Team Ops2

Invoke-Command -ComputerName 192.168.1.10 -AsJob -ScriptBlock { 1..100 | ForEach-Object { Start-Sleep 1; $_ } }

Runs a long-running process as a background job on the remote host to avoid hanging the console.

Link
Receive-Job -Id 1 -Keep

Retrieves the output from a background remote job while keeping the data available for future retrieval.

Link

Advanced Configuration2

Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024

Increases the memory limit for remote shells, useful when running memory-intensive tools remotely.

Link
winrm set winrm/config/winrs @{MaxShellsPerUser="50"}

Increases the maximum number of concurrent shells allowed per user.

Link

Purple Team Validation2

Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { whoami /priv }

Checks the privilege level of the current remote session to validate successful elevation.

Link
Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-MpComputerStatus }

Remotely queries Windows Defender status to check for exclusions or real-time protection state.

Link

Blue Team Detection2

Get-WinEvent -LogName "Microsoft-Windows-WinRM/Operational" -MaxEvents 10

Queries local WinRM operational logs to detect recent incoming connections and errors.

Link
Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-WinEvent -LogName 'Security' -FilterXPath "*[System[EventID=4624] and EventData[Data[@Name='LogonType']='3']]" }

Remotely searches Security logs for Network Logon (Type 3) events associated with WinRM activity.

Link

Incident Response2

Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-NetTCPConnection | Where-Object { $_.LocalPort -eq 5985 } }

Identifies active TCP connections on the remote host specifically on the WinRM HTTP port.

Link
Disable-PSRemoting -Force

Rapidly disables PowerShell Remoting on the system to stop active lateral movement.

Link

JEA Configuration2

New-PSSessionConfigurationFile -Path .\JEAConfig.pssc -SessionType RestrictedRemoteServer

Creates a Just Enough Administration (JEA) configuration file to restrict remote capabilities.

Link
Register-PSSessionConfiguration -Name "Maintenance" -Path .\JEAConfig.pssc

Registers a new endpoint on the local machine using the restricted JEA configuration.

Link

JEA Usage1

Enter-PSSession -ComputerName 192.168.1.10 -ConfigurationName "Maintenance"

Connects to a specific named endpoint (JEA) rather than the default PowerShell endpoint.

Link

Advanced Automation1

Invoke-Command -ComputerName (Get-Content servers.txt) -ScriptBlock { Update-Help } -ThrottleLimit 10

Runs a command against a list of servers read from a file, limiting concurrent operations to 10.

Link

Cleanup3

Remove-Item WSMan:\localhost\Listener\* -Recurse

Deletes all configured WinRM listeners, effectively stopping the machine from accepting connections.

Link
winrm invoke Restore winrm/config

Resets the WinRM configuration to its default installation state.

Link
Stop-Service WinRM

Immediately stops the Windows Remote Management service, terminating all active connections.

Link

Diagnostic1

winrm identify -r:http://192.168.1.10:5985

Queries the remote machine for OS version and WinRM protocol version without a full login.

Link

Proxy Configuration1

winrm set winrm/config/client @{NetworkDelayms="60000"}

Adjusts the network delay timeout for the client, useful for slow or high-latency connections.

Link

Output Handling1

Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-Service } | Select-Object -Property PSComputerName, Name, Status

Filters and formats object-based output returned from the remote session.

Link

Automation1

Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { $env:COMPUTERNAME } -HideComputerName

Executes remotely but suppresses the 'PSComputerName' property from the output display.

Link

Port Forwarding1

Set-Item WSMan:\localhost\Service\EnableCompatibilityHttpListener -Value $true

Enables the compatibility listener to support legacy WinRM clients or specific port forwarding scenarios.

Link

Double Hop2

Enable-WSManCredSSP -Role Client -DelegateComputer "*"

Configures the client to allow credential delegation to any remote host (high security risk).

Link
Enable-WSManCredSSP -Role Server

Configures the server to accept delegated credentials from a client.

Link

Access Control1

Set-PSSessionConfiguration -Name Microsoft.PowerShell -ShowSecurityDescriptorUI

Opens a GUI to interactively modify the Access Control List (ACL) for the default PowerShell endpoint.

Link

Troubleshooting1

Get-WSManInstance -ResourceURI wmicimv2/cim_service -SelectorSet @{Name="WinRM"} -ComputerName 192.168.1.10

Uses WS-Management protocol to directly query the CIM service status on a remote host.

Link

Mass Action1

$sessions = New-PSSession -ComputerName (Get-Content hosts.txt); Invoke-Command -Session $sessions -ScriptBlock { gpupdate /force }

Establishes persistent sessions to multiple hosts listed in a file and runs a group policy update on all.

Link