You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you need finer control than the high-level `Client` wrapper, the lower-level `WSMan` + `RunspacePool` APIs are useful for two common operator problems:
129
+
130
+
- forcing **`WSMAN`** as the Kerberos service/SPN instead of the default `HTTP` expectation used by many PowerShell clients;
131
+
- connecting to a **non-default PSRP endpoint** such as a **JEA** / custom session configuration instead of `Microsoft.PowerShell`.
132
+
133
+
```python
134
+
from pypsrp.wsman import WSMan
135
+
from pypsrp.powershell import PowerShell, RunspacePool
136
+
137
+
wsman = WSMan(
138
+
"srv01.domain.local",
139
+
auth="kerberos",
140
+
ssl=False,
141
+
negotiate_service="WSMAN",
142
+
)
143
+
144
+
with wsman, RunspacePool(wsman, configuration_name="MyJEAEndpoint") as pool, PowerShell(pool) as ps:
145
+
ps.add_script("whoami; Get-Command")
146
+
output = ps.invoke()
147
+
print(output)
148
+
```
149
+
150
+
### Custom PSRP endpoints and JEA matter during lateral movement
151
+
152
+
A successful WinRM authentication does **not** always mean you land in the default unrestricted `Microsoft.PowerShell` endpoint. Mature environments may expose **custom session configurations** or **JEA** endpoints with their own ACLs and run-as behavior.
153
+
154
+
If you already have code execution on a Windows host and want to understand what remoting surfaces exist, enumerate the registered endpoints:
- A **restricted** endpoint can still be enough for lateral movement if it exposes just the right cmdlets/functions for service control, file access, process creation, or arbitrary .NET / external command execution.
169
+
- A **misconfigured JEA** role is especially valuable when it exposes dangerous commands such as `Start-Process`, broad wildcards, writable providers, or custom proxy functions that let you escape the intended restrictions.
170
+
- Endpoints backed by **RunAs virtual accounts** or **gMSAs** change the effective security context of the commands you run. In particular, a gMSA-backed endpoint can provide **network identity on the second hop** even when a normal WinRM session would hit the classic delegation problem.
Two flags are easy to forget and matter in practice:
184
+
185
+
-`/noprofile` is often required when the remote principal is **not** a local administrator.
186
+
-`/allowdelegate` enables the remote shell to use your credentials against a **third host** (for example, when the command needs `\\fileserver\share`).
187
+
188
+
```cmd
189
+
winrs -r:srv01.domain.local /noprofile cmd /c set
190
+
winrs -r:srv01.domain.local /allowdelegate cmd /c dir \\fileserver.domain.local\share
191
+
```
192
+
138
193
Operationally, `winrs.exe` commonly results in a remote process chain similar to:
139
194
140
195
```text
@@ -184,15 +239,18 @@ For multi-hop constraints after landing a first WinRM session, check:
184
239
185
240
-**Interactive PowerShell remoting** usually creates **`wsmprovhost.exe`** on the target.
186
241
-**`winrs.exe`** commonly creates **`winrshost.exe`** and then the requested child process.
242
+
- Custom **JEA** endpoints may execute actions as **`WinRM_VA_*`** virtual accounts or as a configured **gMSA**, which changes both telemetry and second-hop behavior compared to a normal user-context shell.
187
243
- Expect **network logon** telemetry, WinRM service events, and PowerShell operational/script-block logging if you use PSRP rather than raw `cmd.exe`.
188
244
- If you only need a single command, `winrs.exe` or one-shot WinRM execution may be quieter than a long-lived interactive remoting session.
189
245
- If Kerberos is available, prefer **FQDN + Kerberos** over IP + NTLM to reduce both trust issues and awkward client-side `TrustedHosts` changes.
-[Microsoft: Error `0x80090322` when connecting PowerShell to a remote server via WinRM](https://learn.microsoft.com/en-us/troubleshoot/windows-server/system-management-components/error-0x80090322-when-connecting-powershell-to-remote-server-via-winrm)
0 commit comments