# Copyright (c) 2014, Chris Church # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type DOCUMENTATION = ''' name: powershell version_added: historical short_description: Windows PowerShell description: - The only option when using 'winrm' or 'psrp' as a connection plugin. - Can also be used when using 'ssh' as a connection plugin and the C(DefaultShell) has been configured to PowerShell. extends_documentation_fragment: - shell_windows ''' import base64 import os import re import shlex import pkgutil import xml.etree.ElementTree as ET import ntpath from ansible.module_utils._text import to_bytes, to_text from ansible.plugins.shell import ShellBase _common_args = ['PowerShell', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted'] def _parse_clixml(data, stream="Error"): """ Takes a byte string like '#< CLIXML\r\n......'. # Parse each individual element and add the error strings to our stderr list. # https://github.com/ansible/ansible/issues/69550 while data: end_idx = data.find(b"") + 7 current_element = data[data.find(b"