Skip to content
NetworkingBeginner

PowerShell Script to Set Static IP - Network Ethernet

# === CONFIGURATION === $InterfaceAlias = "Ethernet"    # Change this to your actual adapter name (e.g., "Wi-Fi") $IPAddress = "192.168.1.141" $PrefixLength ...

BI
Bison Technical Team Enterprise IT specialists
Updated 19 May 2025 1 min read 161 total views

# === CONFIGURATION ===

$InterfaceAlias = "Ethernet"    # Change this to your actual adapter name (e.g., "Wi-Fi")

Advertisement

$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: $_"

}

YOUR FEEDBACK

Was this guide useful?

Your answer helps us keep BISONKB accurate and practical.

BISON AI

Ask about “PowerShell Script to Set Static IP - Network Ethernet”

This interface is ready to connect to your preferred AI provider. No article or user data is sent until that service is configured.

THE BISON BRIEF

Practical IT knowledge, once a week.

New troubleshooting guides, scripts and infrastructure notes. No noise.

By subscribing, you agree to our privacy policy.