HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/powershell.cpython-310.pyc
o

�N�g��@s:dZddlZddlZddlZe�e�Zdd�Zdd�Z	dS)a�
Common functions for working with powershell

.. note:: The PSModulePath environment variable should be set to the default
    location for PowerShell modules. This applies to all OS'es that support
    powershell. If not set, then Salt will attempt to use some default paths.
    If Salt can't find your modules, ensure that the PSModulePath is set and
    pointing to all locations of your Powershell modules.
�NcCs
|t�vS)a�
    Check if a module exists on the system.

    Use this utility instead of attempting to import the module with powershell.
    Using powershell to try to import the module is expensive.

    Args:

        name (str):
            The name of the module to check

    Returns:
        bool: True if present, otherwise returns False

    Example:

    .. code-block:: python

        import salt.utils.powershell
        exists = salt.utils.powershell.module_exists('ServerManager')
    )�get_modules)�name�r�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/powershell.py�
module_existss
rcCsTt�}d}g}tj�dtj�d��}d�tj�dd��}tj�dd�}|�d	�d
|�d�|�d�g}d
�|�}tj�d|�}|�d
�}|D]
}tj�|�rR|�	|�qE|s\t
�d�|S|D]I}	tj�|	�sgq^t
jj�|	�D]8\}
}}|D]0}
tj�|
�\}}|��|vr�tj�tj�|
��}||vr�|��|��kr�|dd�=|�	|�quqnq^|S)a�
    Get a list of the PowerShell modules which are potentially available to be
    imported. The intent is to mimic the functionality of ``Get-Module
    -ListAvailable | Select-Object -Expand Name``, without the delay of loading
    PowerShell to do so.

    Returns:
        list: A list of modules available to Powershell

    Example:

    .. code-block:: python

        import salt.utils.powershell
        modules = salt.utils.powershell.get_modules()
    )z.psd1z.psm1z.cdxmlz.xamlz.dll�HOME�HOMEPATHz{}\System32ZWINDIRz
C:\WindowsZProgramFileszC:\Program Filesz /.local/share/powershell/Modulesz#/usr/local/share/powershell/Modulesz \WindowsPowerShell\v1.0\Modules\z\WindowsPowerShell\Modules�;ZPSModulePathzDefault paths not foundN)�list�os�environ�get�format�join�split�path�exists�append�log�error�isdir�salt�utilsZos_walk�splitext�lower�basename�normpath)�retZvalid_extensionsZ
root_pathsZhome_dirZ
system_dirZ
program_filesZ
default_pathsZps_module_path�itemZ	root_path�root_dirZsub_dirsZ
file_names�	file_name�	base_nameZfile_extensionZdir_namerrrr,sH�
	

�


���r)
�__doc__�loggingrZsalt.utils.pathr�	getLogger�__name__rrrrrrr�<module>s