utils.windows.powershell module

Windows PowerShell utilities

class utils.windows.powershell.TableHelper

Bases: object

not_in_list_is_nc(value, params, pre_comment_field_text='', comment_value='', post_comment_field_text='')
ps_table_builder(input_lists: List[str], table_items: dict, table_title: str = '', processing_rules: dict = {})

Convert lists (typically resulting from ps_list_cleanup) into tables for display and further processing (in progress–use ps_table_builder_json instead). dict structure is in the form of ‘TableHeader’:”regex”, where TableHeader is the display for the table header row, and the regex is what is used to find the corresponding data in the list

processing_rules expects a dictionary that calls additional processing on certain values

ps_table_builder_json(input_lists_json, table_items: dict, table_title: str = '', processing_rules: dict = {})

Convert lists (typically resulting from ps_list_cleanup with output_json=True) into tables for display and further processing. dict structure is in the form of ‘TableHeader’:”PSListIndex”, where TableHeader is the display for the table header row, and the PSListIndex is what the field is called in the PowerShell list output.

processing_rules expects a dictionary that calls additional processing on certain values

string_not_match_is_mr(value, params, pre_comment_field_text='', comment_value='', post_comment_field_text='')
utils.windows.powershell.ps_list_cleanup(input_string: str, split_string: str = '\n\n', output_json: bool = False) List[str]

Clean up and remove empty sets from PowerShell Format-List results for easier processing. Can also be used to clean up other repeating groups of items with a different split_string.