25 lines
1.0 KiB
PowerShell
25 lines
1.0 KiB
PowerShell
|
|
#Requires -RunAsAdministrator
|
||
|
|
$adapterName = "TwinCAT-Intel PCI Ethernet Adapter (Gigabit)"
|
||
|
|
$ip = "169.254.176.217"
|
||
|
|
$prefix = 16
|
||
|
|
|
||
|
|
$adapter = Get-NetAdapter -Name $adapterName -ErrorAction SilentlyContinue
|
||
|
|
if (-not $adapter) {
|
||
|
|
Write-Error "Adapter '$adapterName' not found. Available adapters:"
|
||
|
|
Get-NetAdapter -Physical | Select-Object Name, InterfaceDescription, Status | Format-Table -AutoSize
|
||
|
|
exit 1
|
||
|
|
}
|
||
|
|
|
||
|
|
Write-Host "Setting $adapterName to $ip/$prefix ..."
|
||
|
|
|
||
|
|
# Remove existing IP addresses on this adapter (IPv4 only)
|
||
|
|
Get-NetIPAddress -InterfaceIndex $adapter.ifIndex -AddressFamily IPv4 -ErrorAction SilentlyContinue | Remove-NetIPAddress -Confirm:$false -ErrorAction SilentlyContinue
|
||
|
|
|
||
|
|
# Set new IP
|
||
|
|
New-NetIPAddress -InterfaceIndex $adapter.ifIndex -IPAddress $ip -PrefixLength $prefix -AddressFamily IPv4 -ErrorAction Stop | Out-Null
|
||
|
|
|
||
|
|
# Verify
|
||
|
|
Get-NetIPAddress -InterfaceIndex $adapter.ifIndex -AddressFamily IPv4 | Select-Object IPAddress, PrefixLength, AddressState
|
||
|
|
|
||
|
|
Write-Host "Done. Now run tc-build-activate-local.ps1 to activate TwinCAT."
|