Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.225.98.134
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/ansible_collections/community/windows/plugins/modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/ansible_collections/community/windows/plugins/modules//win_regmerge.ps1
#!powershell

# Copyright: (c) 2015, Jon Hawkesworth (@jhawkesworth) <jhawkesworth@protonmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

#Requires -Module Ansible.ModuleUtils.ArgvParser
#Requires -Module Ansible.ModuleUtils.CommandUtil
#Requires -Module Ansible.ModuleUtils.Legacy

Function Convert-RegistryPath {
    Param (
        [parameter(Mandatory = $True)]
        [ValidateNotNullOrEmpty()]$Path
    )

    $output = $Path -replace "HKLM:", "HKLM"
    $output = $output -replace "HKCU:", "HKCU"

    Return $output
}

$result = @{
    changed = $false
}
$params = Parse-Args $args

$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true -resultobj $result
$compare_to = Get-AnsibleParam -obj $params -name "compare_to" -type "str" -resultobj $result

# check it looks like a reg key, warn if key not present - will happen first time
# only accepting PS-Drive style key names (starting with HKLM etc, not HKEY_LOCAL_MACHINE etc)

$do_comparison = $False

If ($compare_to) {
    $compare_to_key = $params.compare_to.ToString()
    If (Test-Path $compare_to_key -pathType container ) {
        $do_comparison = $True
    }
    Else {
        $result.compare_to_key_found = $false
    }
}

If ( $do_comparison -eq $True ) {
    $guid = [guid]::NewGuid()
    $exported_path = $env:TEMP + "\" + $guid.ToString() + 'ansible_win_regmerge.reg'

    $expanded_compare_key = Convert-RegistryPath ($compare_to_key)

    # export from the reg key location to a file
    $reg_args = Argv-ToString -Arguments @("reg.exe", "EXPORT", $expanded_compare_key, $exported_path)
    $res = Run-Command -command $reg_args
    if ($res.rc -ne 0) {
        $result.rc = $res.rc
        $result.stdout = $res.stdout
        $result.stderr = $res.stderr
        Fail-Json -obj $result -message "error exporting registry '$expanded_compare_key' to '$exported_path'"
    }

    # compare the two files
    $comparison_result = Compare-Object -ReferenceObject $(Get-Content $path) -DifferenceObject $(Get-Content $exported_path)

    If ($null -ne $comparison_result -and (Get-Member -InputObject $comparison_result -Name "count" -MemberType Properties )) {
        # Something is different, actually do reg merge
        $reg_import_args = Argv-ToString -Arguments @("reg.exe", "IMPORT", $path)
        $res = Run-Command -command $reg_import_args
        if ($res.rc -ne 0) {
            $result.rc = $res.rc
            $result.stdout = $res.stdout
            $result.stderr = $res.stderr
            Fail-Json -obj $result -message "error importing registry values from '$path'"
        }
        $result.changed = $true
        $result.difference_count = $comparison_result.count
    }
    Else {
        $result.difference_count = 0
    }

    Remove-Item $exported_path
    $result.compared = $true

}
Else {
    # not comparing, merge and report changed
    $reg_import_args = Argv-ToString -Arguments @("reg.exe", "IMPORT", $path)
    $res = Run-Command -command $reg_import_args
    if ($res.rc -ne 0) {
        $result.rc = $res.rc
        $result.stdout = $res.stdout
        $result.stderr = $res.stderr
        Fail-Json -obj $result -message "error importing registry value from '$path'"
    }
    $result.changed = $true
    $result.compared = $false
}

Exit-Json $result

Anon7 - 2022
AnonSec Team