Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.218.63.231
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_webpicmd.ps1
#!powershell

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

#Requires -Module Ansible.ModuleUtils.Legacy

$ErrorActionPreference = "Stop"

Function Find-InstalledCommand {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, Position = 0)] [string] $command
    )
    $installed = get-command $command -erroraction Ignore
    write-verbose "$installed"
    if ($installed) {
        return $installed
    }
    return $null
}

Function Find-WebPiCmd {
    [CmdletBinding()]
    param()
    $p = Find-InstalledCommand "webpicmd.exe"
    if ($null -ne $p) {
        return $p
    }
    $a = Find-InstalledCommand "c:\programdata\chocolatey\bin\webpicmd.exe"
    if ($null -ne $a) {
        return $a
    }
    Throw "webpicmd.exe is not installed. It must be installed (use chocolatey)"
}

Function Test-IsInstalledFromWebPI {
    [CmdletBinding()]

    param(
        [Parameter(Mandatory = $true, Position = 0)]
        [string]$package
    )

    $results = &$executable /list /listoption:installed

    if ($LastExitCode -ne 0) {
        $result.webpicmd_error_cmd = $cmd
        $result.webpicmd_error_log = "$results"

        Throw "Error checking installation status for $package"
    }
    Write-Verbose "$results"

    if ($results -match "^$package\s+") {
        return $true
    }

    return $false
}

Function Install-WithWebPICmd {
    [CmdletBinding()]

    param(
        [Parameter(Mandatory = $true, Position = 0)]
        [string]$package
    )

    $results = &$executable /install /products:$package /accepteula /suppressreboot

    if ($LastExitCode -ne 0) {
        $result.webpicmd_error_cmd = $cmd
        $result.webpicmd_error_log = "$results"
        Throw "Error installing $package"
    }

    write-verbose "$results"

    if ($results -match "Install of Products: SUCCESS") {
        $result.changed = $true
    }
}

$result = @{
    changed = $false
}

$params = Parse-Args $args

$package = Get-AnsibleParam -obj $params -name "name" -type "str" -failifempty $true

Try {
    $script:executable = Find-WebPiCmd
    if ((Test-IsInstalledFromWebPI -package $package) -eq $false) {
        Install-WithWebPICmd -package $package
    }

    Exit-Json $result
}
Catch {
    Fail-Json $result $_.Exception.Message
}

Anon7 - 2022
AnonSec Team