HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/customer_local_ops/operating_system/powershell/enable_winexe.ps1
function Ensure-NetFirewallRule {
    param($displayName, $direction, $action, $protocol, $localPort)
    if(Get-NetFirewallRule -DisplayName $displayName -ea SilentlyContinue){
        Remove-NetFirewallRule -DisplayName $displayName
    }
    New-NetFirewallRule -DisplayName $displayName -Direction $direction -Action $action -Protocol $protocol -LocalPort $localPort
}

Enable-PSRemoting -Force

"Configuring firewall"
Ensure-NetFirewallRule -DisplayName "winexe" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 139
netsh advfirewall firewall set rule name=winexe new localport=139,445

# Remove the blocks set up in the image by OH. NOTE: The spaces in the rule names are required. That's how
# the rules were created.
Remove-NetFirewallRule -DisplayName "Block TCP 139 " -ea SilentlyContinue
Remove-NetFirewallRule -DisplayName "Block TCP 445 " -ea SilentlyContinue

"Auto-restart Lanman Server on failure"
sc.exe failure LanManServer reset= 3600 actions= restart/5000/restart/10000/restart/5000

"Fix Lanman Server dependencies"
# SamSS=Security Accounts Manager; Srv2=SMB2 driver
sc.exe config lanmanserver depend= SamSS/Srv2
sc.exe start lanmanserver