Posted on 19-05-2025 | Category: General | Views: 22
# === CONFIGURATION ===
$InterfaceAlias = "Ethernet" # Change this to your actual adapter name (e.g., "Wi-Fi")
$IPAddress = "192.168.1.141"
$PrefixLength = 24 # 255.255.255.0
$DefaultGateway = "192.168.1.1"
$DNSServers = @("8.8.8.8", "8.8.4.4")
# === APPLY STATIC IP ===
Try {
Write-Output "Setting static IP on $InterfaceAlias..."
Remove-NetIPAddress -InterfaceAlias $InterfaceAlias -AddressFamily IPv4 -Confirm:$false -ErrorAction SilentlyContinue
New-NetIPAddress -InterfaceAlias $InterfaceAlias -IPAddress $IPAddress -PrefixLength $PrefixLength -DefaultGateway $DefaultGateway
Set-DnsClientServerAddress -InterfaceAlias $InterfaceAlias -ServerAddresses $DNSServers
Write-Output "Static IP successfully applied!"
} Catch {
Write-Output "Error applying static IP: $_"
}