WinRM and PowerShell Remoting are how Windows estates are administered at scale, and the same channel is one of the most common lateral movement routes once an attacker holds an admin credential. By default, remoting gives members of the local Administrators group a full PowerShell session on every server, which means every automation account and every helpdesk technician with admin rights has unrestricted remote shell access. This guide covers how WinRM authenticates and encrypts, how to configure listeners and authentication safely, how Just Enough Administration (JEA) replaces broad admin rights with constrained endpoints, how service accounts and automation should connect, and which logs show misuse. It assumes you have read the PowerShell Security Guide, which covers script block logging, Constrained Language Mode and AMSI; this page goes deeper on the remoting layer.
This is an independent guide from NHI Mgmt Group, based on Microsoft's public documentation as of November 2026. It is not sponsored or reviewed by Microsoft. Product features change, so confirm settings against Microsoft's current documentation.
Key takeaways
- Remoting is admin by default. Only members of Administrators can connect out of the box, so every admin credential is also a remote shell credential (ATT&CK T1021.006 Windows Remote Management).
- HTTP on 5985 is encrypted, but not always authenticated both ways. Kerberos gives mutual authentication and message encryption; NTLM verifies the user but not the server, and Basic sends credentials in clear text. Keep Basic and
AllowUnencryptedoff and use HTTPS on 5986 where Kerberos is not available. - JEA turns admin access into named tasks. A JEA endpoint runs a
RestrictedRemoteServersession in NoLanguage mode, exposes only listed commands, and runs them as a temporary virtual account, so the connecting user needs no admin rights. - Avoid CredSSP and fixed RunAs credentials. Microsoft warns CredSSP caches credentials on the remote server; fixed
RunAsCredentialendpoints are not JEA-aware and lose user attribution. - Log both sides of the identity. Event 4104 with module or script block logging records the ConnectedUser and RunAsUser, and WinRM Operational event 193 records both SIDs for each JEA session.
How identity and access work in WinRM
WinRM is Microsoft's implementation of WS-Management. The WinRM service runs as Network Service, accepts connections on its listeners, and starts an isolated host process (wsmprovhost.exe) running as the authenticated user for each PowerShell session, so one user's session cannot reach another's process. Normal Windows access control then applies to everything the session does.
| Element | Default | Security meaning |
|---|---|---|
| HTTP listener | TCP 5985 | Traffic encrypted at message level after authentication with Kerberos or NTLM |
| HTTPS listener | TCP 5986 (not created by default) | TLS; needs a Server Authentication certificate whose CN or SAN matches the host name |
| Who can connect | Administrators group | Every local admin, including service and automation accounts, has a remote shell |
| Firewall rule | Private profile: any source; Public profile: same subnet only | Do not widen the public rule; restrict sources to management subnets |
| Kerberos | On; used when connecting by computer name in a domain | Mutual authentication, no reusable credential sent; AES-256 on modern systems |
| Negotiate | On | Kerberos for domain accounts, NTLM for local accounts or IP addresses |
| NTLM to IP addresses or workgroup hosts | Blocked unless HTTPS is used or the host is in the client's TrustedHosts | User verified, server not verified; message encryption uses RC4 |
| Basic (service) | Off | Credentials in clear text; never enable on HTTP |
| CredSSP (client and service) | Off | Delegates the user's full credentials to the target |
| AllowUnencrypted (client and service) | False | Must stay false |
TrustedHosts is not a trust list. Microsoft describes it as the list of hosts for which you suppress the error raised when the server's identity cannot be verified; computers in it are not authenticated, so credentials may be sent to an impostor. Keep it empty and use Kerberos or HTTPS instead. See the NTLM Deprecation and Elimination Guide.
Admin roles and privileged access
The default model gives a binary choice: no remote access, or full admin. JEA replaces it with endpoints that expose specific tasks. A DNS operator can restart the DNS service and clear the cache on a domain controller without being in Domain Admins.
How a JEA endpoint is built
- Role capability file (.psrc): created with
New-PSRoleCapabilityFileand stored in aRoleCapabilitiesfolder inside a PowerShell module. It listsVisibleCmdlets,VisibleFunctionsandVisibleExternalCommands, optionally with allowed parameter values. - Session configuration file (.pssc): created with
New-PSSessionConfigurationFile. It setsSessionType = 'RestrictedRemoteServer', maps groups to roles inRoleDefinitions, chooses the run-as identity and setsTranscriptDirectory. Validate withTest-PSSessionConfigurationFile. - Registration:
Register-PSSessionConfiguration -Name <endpoint> -Path <file>. To change mappings, unregister and re-register. - Two separate gates: the endpoint ACL (who may connect, at least Invoke rights, seen in
Get-PSSessionConfigurationPermission) andRoleDefinitions(what they may run). Check both.
A RestrictedRemoteServer session runs in NoLanguage mode with only eight default commands (Clear-Host, Exit-PSSession, Get-Command, Get-FormatData, Get-Help, Measure-Object, Out-Default, Select-Object) and no providers or external programs until a role adds them.
Choosing the run-as identity
| Option | How it works | Use when | Watch out for |
|---|---|---|---|
Virtual account (RunAsVirtualAccount) | Temporary local account per session, destroyed at the end; user never knows its credentials | Default choice for local administration tasks | Member of Administrators (or Domain Admins on a DC) unless you set RunAsVirtualAccountGroups, which removes the default admin membership |
Group managed service account (GroupManagedServiceAccount) | Session runs as a gMSA with a network identity | Task must reach file shares or web services on other hosts | All users share one identity, so attribution relies on transcripts and event 193; scope the gMSA tightly. See the Group Managed Service Accounts (gMSA) Guide |
| No run-as (pass-through) | User's own token | Not recommended | User needs privileged group membership and can bypass JEA |
Fixed RunAsCredential | Stored credential shared by all users | Never on JEA endpoints | Not JEA-aware, everyone gets the same role, credential must be maintained |
Role design rules from Microsoft's security guidance
- No wildcards:
*-ProcessincludesStart-Process, which can launch any program with admin rights. List each cmdlet. - No FileSystem or Certificate provider: file write access bypasses controls; the Certificate provider can expose private keys. Use
MountUserDrive(default 50 MB per user) for file transfer. - No runspace creation: exclude
*-Jobcmdlets and Windows Compatibility, plusUpdate-TypeData,Remove-TypeData,Update-FormatDataandTrace-Command. ExcludeInvoke-Expressionand anything that runs arbitrary script. - Do not reimplement the default proxies for the eight default commands; custom versions reopen gaps.
- Require extra conditions:
RequiredGroupsadds And/Or group conditions, for example membership of a just-in-time group and a smart card or MFA logon group. - JEA does not constrain admins: anyone who is already a local administrator can use RDP, remote MMC or the default endpoint, or edit the JEA configuration. JEA only reduces risk once the standing admin rights are removed. Pair it with the Privileged Access Management Guide approach to just-in-time elevation.
Integrations, API tokens and service accounts
Configuration management tools, monitoring agents, backup software, deployment pipelines and orchestration platforms connect over WinRM using service accounts. These are high-value non-human identities: one account often has admin rights on hundreds of servers.
- Give automation its own JEA endpoint: a deployment account that only runs a signed deployment function should connect to an endpoint exposing that function, not to
Microsoft.PowerShellwith full admin. - Prefer gMSAs for the calling account: where the automation runs on Windows, a gMSA removes the static password. See the Windows Services and Service Account Security Guide.
- Use Kerberos, by name: connect by fully qualified host name so Kerberos is used; tools that connect by IP fall back to NTLM and push you towards TrustedHosts.
- Linux and cross-platform clients: tools that connect from Linux often default to NTLM or Basic. Configure Kerberos or certificate authentication over HTTPS, and never enable Basic on the service to make a tool work.
- Do not store credentials in scripts: plain-text passwords in
-Credentialobjects built from strings, in scheduled task arguments or in pipeline variables are the usual leak. Use the platform's secret store or a vault. See the Secrets Management Guide. - Second hop: when a remote command must reach a third server, Microsoft ranks the options. CredSSP caches credentials on the intermediate server and should be enabled only in the most trusted environments; unconstrained Kerberos delegation is less secure than CredSSP and for testing only; resource-based Kerberos constrained delegation stores nothing but is not the documented second-hop route for WinRM itself, so confirm with Microsoft; JEA with a virtual account or gMSA avoids passwords but needs configuration on each intermediate server. See the Kerberos Delegation Security Guide.
Logging and detection
| Source | Event | What it tells you |
|---|---|---|
| Microsoft-Windows-PowerShell/Operational | 4104 (script block logging) | Commands run, including in remote sessions; for JEA, includes ConnectedUser and RunAsUser |
| Microsoft-Windows-Windows Remote Management/Operational | 193 | New JEA session with SID and name of connecting user and RunAs user, for correlating virtual account activity to a person |
| JEA transcript directory | Transcript files | Start time, Username, RunAs User and each CommandInvocation and ParameterBinding; written by Local System, so lock the folder against standard users |
| Security log | 4624 logon type 3 followed by wsmprovhost.exe process creation (4688 or EDR telemetry) | Inbound remoting session; unusual source hosts or accounts indicate lateral movement |
| WinRM configuration | winrm get winrm/config, Get-PSSessionConfiguration | Drift: Basic or AllowUnencrypted enabled, new endpoints, widened endpoint ACLs, TrustedHosts set to * |
Alert on remoting sessions from workstations that are not admin workstations, on service accounts connecting from hosts other than their automation server, on Register-PSSessionConfiguration or Set-PSSessionConfiguration outside change windows, and on CredSSP being enabled. ATT&CK techniques to map detections to: T1021.006 Windows Remote Management, T1059.001 PowerShell and T1078.002 Domain Accounts. See the Active Directory Security Monitoring and Event IDs Guide and the Lateral Movement Guide.
Metrics
- Standing remote admins: number of accounts with unrestricted remoting rights per server tier, trending down as JEA rolls out.
- JEA coverage: percentage of recurring operational tasks delivered through JEA endpoints.
- Legacy authentication settings: servers with Basic, AllowUnencrypted, CredSSP or a non-empty TrustedHosts (target zero without exception).
- Attribution: percentage of JEA and remoting sessions where event 193 or 4104 ties a virtual account or gMSA action to a named user.
- Source restriction: percentage of servers where the WinRM firewall rule allows only management subnets.
Hardening baseline
- Restrict network reach first: scope the WinRM firewall rules to management subnets and privileged access workstations. See the Privileged Access Workstations Guide.
- Enforce authentication settings by Group Policy: under Computer Configuration, Administrative Templates, Windows Components, Windows Remote Management, keep Basic authentication and unencrypted traffic disallowed on both client and service, keep CredSSP disabled, and set channel binding hardening (
CbtHardeningLevel, default Relaxed) to Strict where clients support it. Use the Microsoft Security Baselines Guide values as the starting point. - Add HTTPS where Kerberos is unavailable: install a CA-issued certificate with the Server Authentication EKU and matching CN or SAN, run
winrm quickconfig -transport:https, then confirm the thumbprint withwinrm enumerate winrm/config/listener. Do not use self-signed certificates. - Build JEA endpoints for the top tasks: start with the most frequent helpdesk and operations tasks. Run in a pilot ring with transcripts on and use
Get-PSSessionCapability -ConfigurationName <endpoint> -Username <user>to confirm effective rights. - Remove standing admin membership: once a role's tasks work through JEA, remove its members from local Administrators. Keep a break-glass path documented.
- Restrict the default endpoint: limit who may connect to
Microsoft.PowerShellwithSet-PSSessionConfiguration -SecurityDescriptorSddlto a small admin group, so day-to-day users can only reach JEA endpoints. - Turn on logging before go-live: script block or module logging, the WinRM Operational log and transcript collection into your SIEM.
- Roll back safely: JEA endpoints are additive; rollback is restoring the removed group membership or unregistering the endpoint with
Unregister-PSSessionConfiguration. Keep .psrc and .pssc files in source control and deploy them with configuration management or DSC so every server has the same version.
Small and large estates
- Small: keep Kerberos over HTTP inside the domain, restrict the firewall, build two or three JEA endpoints for helpdesk tasks, and remove helpdesk staff from Administrators.
- Large: publish role capabilities as a versioned internal module, assign endpoints per server tier, integrate
RequiredGroupswith just-in-time groups, and alert on any session to the default endpoint by non-tier-0 staff.
Common misconfigurations
- TrustedHosts set to
*: done to make NTLM by IP work, it disables server authentication for every target and lets credentials go to any host that answers. - Basic or AllowUnencrypted enabled for a third-party tool: credentials and session content cross the network in clear text.
- CredSSP left on after troubleshooting: credentials are cached on the remote host, available to anyone who compromises it (T1003.001 LSASS Memory).
- JEA roles with wildcards or
Start-Process: a "restricted" endpoint that is an admin shell in practice. - Virtual accounts left in Administrators: forgetting
RunAsVirtualAccountGroupsmeans every role runs as full local admin, or Domain Admins on a domain controller. - JEA deployed but admin rights not removed: users keep RDP and the default endpoint, so JEA adds logging but no restriction.
- Automation accounts with domain-wide admin: one account with remoting rights on every server, a password in a script and no source restriction is a complete lateral movement path.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev. 5 | AC-17 Remote Access; AC-6 Least Privilege; SC-8 Transmission Confidentiality and Integrity; AU-2 and AU-12 | Remoting restrictions, JEA roles, encryption and HTTPS, session logging |
| NIST CSF 2.0 | PR.AA-05; PR.DS-02; PR.PS-04; DE.CM-03 | Least privilege, data in transit, log generation, monitoring of administrator activity |
| CIS Controls v8.1 | Control 4 Secure Configuration; Control 5 Account Management; Control 6 Access Control Management; Control 8 Audit Log Management | WinRM baseline, service account control, endpoint ACLs, logging |
| ISO/IEC 27001:2022 Annex A | A.8.2 Privileged access rights; A.8.15 Logging; A.8.20 Networks security | Delegated administration, session records, management network restriction |
| MITRE ATT&CK | T1021.006; T1059.001; T1078.002; T1003.001; T1550.002 | Remoting abuse, PowerShell execution, use of stolen admin credentials |
Practitioner checklist
- Scope WinRM firewall rules on every server to management subnets and admin workstations.
- Enforce by Group Policy: Basic off, AllowUnencrypted off, CredSSP off, TrustedHosts empty.
- Use Kerberos by host name inside the domain and CA-issued HTTPS listeners on 5986 elsewhere.
- Build JEA endpoints with explicit cmdlet lists, no wildcards, no FileSystem provider and virtual accounts limited by
RunAsVirtualAccountGroups. - Remove standing local admin rights once JEA covers a role's tasks, and restrict the default
Microsoft.PowerShellendpoint. - Give each automation tool its own gMSA or vaulted credential and its own endpoint, limited to its source host.
- Enable script block logging, collect WinRM Operational event 193 and JEA transcripts, and alert on new or changed session configurations.
- Audit effective rights quarterly with
Get-PSSessionConfigurationandGet-PSSessionCapability.
Standards and references
- Microsoft Learn: Security considerations for PowerShell Remoting using WinRM
- Microsoft Learn: Just Enough Administration overview
- Microsoft Learn: JEA security considerations
- Microsoft Learn: JEA session configurations
- Microsoft Learn: Auditing and reporting on JEA
- Microsoft Learn: Installation and configuration for Windows Remote Management
- Microsoft Learn: Making the second hop in PowerShell Remoting
- MITRE ATT&CK: Remote Services: Windows Remote Management
Related NHI Mgmt Group resources: PowerShell Security Guide · Group Managed Service Accounts (gMSA) Guide · Lateral Movement Guide · Privileged Access Management Guide · Local Administrator Password Solution (LAPS) Guide