Skip to main content

Library for WinRM

Project description

WSMANIO

Examples

Shell

import asyncio

from wsmanio.shell import Encoding, Process, WinRS
from wsmanio.wsman import HTTPTransport, WSMan

async def main():
    async with (
        WSMan(
            transport=HTTPTransport(
                server_url='https://windows-server.lan:5986/wsman',
                username='username',
                password='password',
            )
        ) as wsman,
        WinRS(
            wsman=wsman,
            encoding=Encoding.UTF8,
        ) as shell,
    ):
        process = Process(shell=shell, executable='powershell', arguments=['-command', '"Get-Process | Select Name"'])
        await process.invoke()
        print(process.rc)
        print(process.stdout.decode(errors='replace'))
        print(process.stderr.decode(errors='replace'))


if __name__ == '__main__':
    asyncio.run(main())

WMI

import asyncio

from wsmanio.wmi import WMIClient
from wsmanio.wsman import HTTPTransport, WSMan

async def main():
    async with WSMan(
        transport=HTTPTransport(
            server_url='https://windows-server.lan:5986/wsman',
            username='username',
            password='password',
        )
    ) as wsman:
        wmi = WMIClient(wsman=wsman)
        result = await (
            wmi.virtualization
            .Msvm_ComputerSystem(Name='9E41B16C-E617-4B54-9515-1905CDA18C3F', CreationClassName='Msvm_ComputerSystem')
            .get()
        )
        print(result)

        result = await (
            wmi.cimv2
            .Win32_Process()
            .Create(CommandLine='notepad.exe', CurrentDirectory='C:\\')
        )
        print(result)

        result = await (
            wmi.virtualization
            .Msvm_ComputerSystem(Name='9E41B16C-E617-4B54-9515-1905CDA18C3F')
            .RequestStateChange(RequestedState='3')
        )
        print(result)


if __name__ == '__main__':
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsmanio-0.0.4.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wsmanio-0.0.4-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file wsmanio-0.0.4.tar.gz.

File metadata

  • Download URL: wsmanio-0.0.4.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wsmanio-0.0.4.tar.gz
Algorithm Hash digest
SHA256 d374c48f5da8594f01622475d9b8aeccc7fb22fab91a1b175790644fb57fa8d8
MD5 58ee3b85c4083a558a141ae8ad6b8e75
BLAKE2b-256 2def6920f9a1954c93f3361b58475689b75c7cab59314641c7b9f9f82afbf871

See more details on using hashes here.

File details

Details for the file wsmanio-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: wsmanio-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wsmanio-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f8331cf8a7e59aacf5b8d998ebb4541bc38ca24d8572460e61cdaa9bc8a9bfdd
MD5 0486f245fff32a49c1e206d0d5cc0908
BLAKE2b-256 af27b9d03e2f4789e9dd19321c635d8f56efc2aa9fd0d682413aa2872f7e55e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page