Skip to main content

powershell-commands-wrapper

A Python wrapper around subprocess to run PowerShell commands and retrieve their outputs.

Tested on Windows only. The package may work on Linux with PowerShell (pwsh) installed, but this is not tested.

Installation

pip install powershell-commands-wrapper

Usage

Commands are expressed as a list of strings — the first element is the cmdlet name, followed by its arguments.

import powershell

stdout = powershell.run(["Write-Host", "hello world"])
# stdout = "hello world"

JSON output

Pass as_json=True to retrieve the output as a JSON object:

import powershell

disks = powershell.run(["Get-Disk"], as_json=True)
# disks = [{"Size": 10737418240, "DiskNumber": 1, "PartitionStyle": "MBR", ...}]

Error handling

By default a powershell.PowerShellError is raised when the exit code is non-zero. Set raise_on_error=False to suppress this:

try:
    powershell.run(["Some-Command"])
except powershell.PowerShellError as e:
    print(e.result.returncode)
    print(e.result.stderr)

# Or ignore errors entirely
powershell.run(["Some-Command"], raise_on_error=False)

About Nuabee

This package is maintained by Nuabee, a company that helps businesses improve their IT resiliency.

Metadata

Release files for powershell-commands-wrapper 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for powershell-commands-wrapper 0.1.0
File Size Uploaded Provenance Actions
powershell_commands_wrapper-0.1.0.tar.gz 10.3 kB Without provenance Details for powershell_commands_wrapper-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for powershell-commands-wrapper 0.1.0
File Interpreter ABI Platform Actions
powershell_commands_wrapper-0.1.0-py3-none-any.whl Python 3 none any Details for powershell_commands_wrapper-0.1.0-py3-none-any.whl

Total release size: 14.3 kB

Release files / powershell_commands_wrapper-0.1.0.tar.gz

Download URL powershell_commands_wrapper-0.1.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fc9d38ff6040d01950560429acfd6b40ffd66856287401e90851fefe5cc2fe22
BLAKE2b-256 checksum
How to use checksums
7f5974a3a2e5a0a204fda91c08481ae82c38e49485355d685468ce62a1c55709
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / powershell_commands_wrapper-0.1.0-py3-none-any.whl

Download URL powershell_commands_wrapper-0.1.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cd11e2edbb2d4281c040cce9fd92e89652af1cbf5c6d31543b6887ee3398f3b
BLAKE2b-256 checksum
How to use checksums
cc49b50bd2cca408d60cb142e931266dd9c56e2cb943ef85b6c5c3e39284474d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for powershell-commands-wrapper 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page