winrmcp

raw JSON →
0.0.3 verified Mon Apr 27 auth: no python maintenance

A Python package to execute commands on remote Windows machines and copy files to the remote machine using WinRM. Current version 0.0.3, requires Python >=3.6. Low release cadence, last updated in 2017.

pip install winrmcp
error AttributeError: module 'winrmcp' has no attribute 'WinRMCP'
cause Attempting to import WinRMCP (capitalized) instead of winrmcp (lowercase).
fix
Change import to from winrmcp import winrmcp.
error winrm.exceptions.InvalidCredentialsError: Authentication failed
cause Incorrect username/password or authentication method not supported (e.g., 'basic' requires HTTPS and server cert validation handling).
fix
Ensure correct credentials, use transport='basic' with server_cert_validation='ignore', or switch to 'kerberos'/'ntlm' if configured.
error ConnectionError: Could not connect to the remote host
cause Host unreachable, firewall blocking WinRM ports (5985 HTTP, 5986 HTTPS), or WinRM service not enabled.
fix
Verify network connectivity, check WinRM service is running on target, and ensure firewall allows the port.
breaking Incorrect import: the main class is `winrmcp` (lowercase), not `WinRMCP`. Importing `WinRMCP` will raise AttributeError.
fix Use `from winrmcp import winrmcp`.
gotcha The `copy()` method's `direction` parameter defaults to 'put'. Use `direction='get'` to copy files from remote to local.
fix Explicitly specify direction when copying from remote.
gotcha The library requires pywinrm and its dependencies. On non-Windows systems, you may need to install additional packages for Kerberos or NTLM authentication.
fix Ensure pywinrm and all its extras are installed (e.g., `pip install pywinrm[all]`).

Basic usage: create a client, run commands, and copy files.

from winrmcp import winrmcp

# Connect to remote Windows host
client = winrmcp(
    hostname='192.168.1.100',
    username='Administrator',
    password='password',
    transport='basic',
    server_cert_validation='ignore'
)

# Run a command
result = client.run_cmd('ipconfig', ['/all'])
print(result.std_out, result.std_err, result.status_code)

# Copy file to remote
client.copy('local_file.txt', 'C:\\Remote\\path\\file.txt')

# Copy file from remote
client.copy('C:\\Remote\\file.txt', 'local_copy.txt', direction='get')