s = winrm.Session(host, auth=(username, password))task_folder = '\RPA\\'
command = 'schtasks /query /fo csv'
result = s.run_cmd(command)
print(result.std_out)
lines = result.std_out.decode().splitlines()
headers = [header.strip('"') for header in lines[0].split(',')]
tasks = []
for line in lines[1:]:task_values = [value.strip('"') for value in line.split(',')]task = {header: value for header, value in zip(headers, task_values)}tasks.append(task)
json_output = json.dumps(tasks)
print(json_output)
lines = result.std_out.decode().splitlines()
headers = [header.strip('"') for header in lines[0].split(',')]
tasks = []
for line in lines[1:]:task_values = [value.strip('"') for value in line.split(',')]task = {header: value for header, value in zip(headers, task_values)}tasks.append(task)
for task in tasks:print(task)
print('len tasks',len(tasks))