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',
        )
        print(result)

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

        result = await wmi.virtualization.Msvm_ComputerSystem.RequestStateChange(
            selectors={'Name': '9E41B16C-E617-4B54-9515-1905CDA18C3F'},
            arguments={'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.2.tar.gz (11.2 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.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wsmanio-0.0.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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.2.tar.gz
Algorithm Hash digest
SHA256 b67f5be34487d853b7847fc285592c1d7f1b8b06e602253e1e30cdd279acb0a3
MD5 46da92dd56b93b76c63a0981559ee68b
BLAKE2b-256 996158468965abbeb87f5c9831d7575def9ca4f788398d4ea1c29262c3b785db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wsmanio-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 23829407c50f3697a4e64491533fa13345ec3f49d516c870804a09ed198391bb
MD5 c7ed766765b9dab69c5b0061b4a00cdc
BLAKE2b-256 5113e41bfdc5db8d51896e7ff82b0ead8966c4c506c378ed59a91aaa15c1dd8d

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