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

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

#Requires -Module Ansible.ModuleUtils.Legacy

$params = Parse-Args $args -supports_check_mode $true
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false
$diff_support = Get-AnsibleParam -obj $params -name "_ansible_diff" -type "bool" -default $false

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

$result = @{
    changed = $false
    previous_timezone = $timezone
    timezone = $timezone
}

Try {
    # Get the current timezone set
    $result.previous_timezone = $(tzutil.exe /g)
    If ($LASTEXITCODE -ne 0) {
        Throw "An error occurred when getting the current machine's timezone setting."
    }

    if ( $result.previous_timezone -eq $timezone ) {
        Exit-Json $result "Timezone '$timezone' is already set on this machine"
    }
    Else {
        # Check that timezone is listed as an available timezone to the machine
        $tzList = $(tzutil.exe /l).ToLower()
        If ($LASTEXITCODE -ne 0) {
            Throw "An error occurred when listing the available timezones."
        }

        $tzExists = $tzList.Contains(($timezone -Replace '_dstoff').ToLower())
        if (-not $tzExists) {
            Fail-Json $result "The specified timezone: $timezone isn't supported on the machine."
        }

        if ($check_mode) {
            $result.changed = $true
        }
        else {
            tzutil.exe /s "$timezone"
            if ($LASTEXITCODE -ne 0) {
                Throw "An error occurred when setting the specified timezone with tzutil."
            }

            $new_timezone = $(tzutil.exe /g)
            if ($LASTEXITCODE -ne 0) {
                Throw "An error occurred when getting the current machine's timezone setting."
            }

            if ($timezone -eq $new_timezone) {
                $result.changed = $true
            }
        }

        if ($diff_support) {
            $result.diff = @{
                before = "$($result.previous_timezone)`n"
                after = "$timezone`n"
            }
        }
    }
}
Catch {
    Fail-Json $result "Error setting timezone to: $timezone."
}

Exit-Json $result

Anon7 - 2022
AnonSec Team