Converts the output of a powershell (Get-...)/wmic command to a dict
Project description
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...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wmicprocsdict-0.10.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file wmicprocsdict-0.10.tar.gz
.
File metadata
- Download URL: wmicprocsdict-0.10.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81d93f7db35a3e4a27891c225e502a878c348d5901ad78432ba8dc71d348440c |
|
MD5 | 83c8cb0912bf4c9d95f1397a53b9812d |
|
BLAKE2b-256 | b84e3fe4ea879dfe32c16833f6525b952eb7f6e462b93f1a7df2497ef38f7330 |
File details
Details for the file wmicprocsdict-0.10-py3-none-any.whl
.
File metadata
- Download URL: wmicprocsdict-0.10-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb5b654da797f91494390d113e464be2fab1b1a45bc9d7e398b12e2209afa93a |
|
MD5 | 83183397b12c52c40132cde567ba9d0c |
|
BLAKE2b-256 | 0df02f10aae25cc92b2150ee6c76439004c871c0df6c233fe2e0f9ee419fe11b |