Converts the output of a powershell (Get-...)/wmic command to a dict
pip install wmicprocsdict
Tested against Windows 10 / Python 3.11 / Anaconda
Args:
cmd (str): The command to execute.
convert_dtypes_with_ast (bool, optional): Whether to convert column data types to their appropriate types using the ast module. Defaults to True.
format_powershell (bool, optional): Format to: f'powershell "{cmd} | Format-Table *"'. Defaults to False.
cols (int): Number of columns for the console. Defaults to 9999999.
lines (int): Number of lines for the console. Defaults to 1.
Returns:
dict: A dictionary representing the command output.
Example:
from wmicprocsdict import get_dict_from_command
d1 = get_dict_from_command(
cmd="Get-Process",
convert_dtypes_with_ast=True,
format_powershell=True,
cols=9999999,
lines=1,
)
d2 = get_dict_from_command(
cmd=f'powershell "Get-Process | Format-Table *"',
convert_dtypes_with_ast=True,
format_powershell=False,
cols=9999999,
lines=1,
)
e1 = get_dict_from_command(
cmd="wmic process",
convert_dtypes_with_ast=True,
format_powershell=False,
cols=9999999,
lines=1,
)
d3 = get_dict_from_command(
cmd="Get-Service",
convert_dtypes_with_ast=True,
format_powershell=True,
cols=9999999,
lines=1,
)
d4 = get_dict_from_command(
cmd=f'powershell "Get-Service | Format-Table *"',
convert_dtypes_with_ast=True,
format_powershell=False,
cols=9999999,
lines=1,
)
print(d1)
print(d2)
print(e1)
print(d3)
print(d4)
# {0: {'Id': 56, 'PriorityClass': 'Normal', 'FileVersion': (6, 6, 0, 0), 'HandleCount': 430, 'WorkingSet': 32923648, 'PagedMemorySize': 38731776, 'PrivateMemorySize': 38731776, 'Virt...
# {0: {'Id': 56, 'PriorityClass': 'Normal', 'FileVersion': (6, 6, 0, 0), 'HandleCount': 430, 'WorkingSet': 32923648, 'PagedMemorySize': 38731776, 'PrivateMemorySize': 38731776, 'Virt...
# {0: {'CommandLine': '', 'CreationClassName': 'Win32_Process', 'CreationDate': '20240325180030.969217-180', 'CSCreationClassName': 'Win32_ComputerSystem', 'CSName': '...
# {0: {'RequiredServices': {}, 'CanPauseAndContinue': False, 'CanShutdown': False, 'CanStop': False, 'DisplayName': 'Agent Activation Runtime_c5578', 'DependentServices': {}, 'Machin...
# {0: {'RequiredServices': {}, 'CanPauseAndContinue': False, 'CanShutdown': False, 'CanStop': False, 'DisplayName': 'Agent Activation Runtime_c5578', 'DependentServices': {}, 'Machin...
Metadata
Release files for wmicprocsdict 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| wmicprocsdict-0.10.tar.gz | 5.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wmicprocsdict-0.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.8 kB
Release files / wmicprocsdict-0.10.tar.gz
| Download URL | wmicprocsdict-0.10.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81d93f7db35a3e4a27891c225e502a878c348d5901ad78432ba8dc71d348440c
|
|
BLAKE2b-256 checksum How to use checksums |
b84e3fe4ea879dfe32c16833f6525b952eb7f6e462b93f1a7df2497ef38f7330
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / wmicprocsdict-0.10-py3-none-any.whl
| Download URL | wmicprocsdict-0.10-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb5b654da797f91494390d113e464be2fab1b1a45bc9d7e398b12e2209afa93a
|
|
BLAKE2b-256 checksum How to use checksums |
0df02f10aae25cc92b2150ee6c76439004c871c0df6c233fe2e0f9ee419fe11b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for wmicprocsdict 0.10
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.