HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible_collections/community/windows/plugins/modules/win_netbios.ps1
#!powershell

# Copyright: (c) 2019, Thomas Moore (@tmmruk) <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

#AnsibleRequires -CSharpUtil Ansible.Basic

$spec = @{
    options = @{
        state = @{ type = "str"; choices = "enabled", "disabled", "default"; required = $true }
        adapter_names = @{ type = "list"; elements = "str"; required = $false }
    }
    supports_check_mode = $true
}

$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
$module.Result.reboot_required = $false

$state = $module.Params.state
$adapter_names = $module.Params.adapter_names

switch ( $state ) {
    'default' { $netbiosoption = 0 }
    enabled { $netbiosoption = 1 }
    disabled { $netbiosoption = 2 }
}

if (-not $adapter_names) {
    # Target all network adapters on the system
    $get_params = @{
        ClassName = 'Win32_NetworkAdapterConfiguration'
        Filter = 'IPEnabled=true'
        Property = @('MacAddress', 'TcpipNetbiosOptions')
    }
    $target_adapters_config = Get-CimInstance @get_params
}
else {
    $get_params = @{
        Class = 'Win32_NetworkAdapter'
        Filter = ($adapter_names | ForEach-Object -Process { "NetConnectionId='$_'" }) -join " OR "
        KeyOnly = $true
    }
    $target_adapters_config = Get-CimInstance @get_params | Get-CimAssociatedInstance -ResultClass 'Win32_NetworkAdapterConfiguration'
    if (($target_adapters_config | Measure-Object).Count -ne $adapter_names.Count) {
        $module.FailJson("Not all of the target adapter names could be found on the system. No configuration changes have been made. $adapter_names")
    }
}

foreach ($adapter in $target_adapters_config) {
    if ($adapter.TcpipNetbiosOptions -ne $netbiosoption) {
        if (-not $module.CheckMode) {
            $result = Invoke-CimMethod -InputObject $adapter -MethodName SetTcpipNetbios -Arguments @{TcpipNetbiosOptions = $netbiosoption }
            switch ( $result.ReturnValue ) {
                0 { <# Success no reboot required #> }
                1 { $module.Result.reboot_required = $true }
                100 {
                    $msg = "DHCP not enabled on adapter $($adapter.MacAddress). Unable to set default. Try using disabled or enabled options instead."
                    $module.Warn($msg)
                }
                default {
                    $msg = "An error occurred while setting TcpipNetbios options on adapter $($adapter.MacAddress). Return code $($result.ReturnValue)."
                    $module.FailJson($msg)
                }
            }
        }
        $module.Result.changed = $true
    }
}

$module.ExitJson()