1

So I was on here with a different question, and I've made some progress in Identifying the issue. I have a network that isn't allowed to have DHCP, and all of our MTR Pcs live on it static. intermittently they come up like this after their nightly reboot,

InterfaceAlias       : Ethernet 3
InterfaceIndex       : 21
InterfaceDescription : PANGP Virtual Ethernet Adapter
NetProfile.Name      : Unidentified network
IPv4Address          : 169.254.24.253
                       10.245.2.160
IPv4DefaultGateway   :
DNSServer            : 134.20.248.5
                       134.20.248.21

enter image description here enter image description here

you'll notice that there is a link local address taking precedent over the set static, and Wireshark is actually seeing a DHCP request going out. Bumping the port, disabling and reenabling the Nic, or even unplugging the Ethernet cable and putting it back all fix this, and they return to their static address. while we are tracking down the issue, I'm trying to deploy a Power shell script to simply Bump the PCs NIC this is what I have, but it's not quite working (super newb to Powershell) at this point; just trying to get the Wifi adaptor to disable.

Example of my test environment here:

InterfaceAlias       : Ethernet 3
InterfaceIndex       : 21
InterfaceDescription : PANGP Virtual Ethernet Adapter
NetProfile.Name      : Unidentified network
IPv4Address          : 10.245.2.160
IPv4DefaultGateway   :
DNSServer            : 134.20.248.5
                       134.20.248.21

InterfaceAlias : Wi-Fi InterfaceIndex : 19 InterfaceDescription : Intel(R) Wi-Fi 6 AX201 160MHz NetProfile.Name : Space Interweb IPv4Address : 192.168.1.154 IPv4DefaultGateway : 192.168.1.1 DNSServer : 192.168.1.1

InterfaceAlias : Ethernet 2 InterfaceIndex : 13 InterfaceDescription : Check Point Virtual Network Adapter For Endpoint VPN Client NetAdapter.Status : Disconnected

enter image description here

Code I'm attempting

PS C:\Users\flatbe> if (Get-NetIPConfiguration | ? IPv4Address -match "10"){ Get-NetIPConfiguration | ? interfaceAlias -match "Wi" | Disable-NetAdapter -Confirm:$false }

I have since tried

>> Get-NetIPConfiguration |
>>     ? InterfaceIndex -match "19" |
>>     Restart-NetAdapter

which works but this doesnt

>> Get-NetIPConfiguration |
>>     ? IPv4Address[] -match "141" |
>>     Restart-NetAdapter

how would I write this properly?

I stepped up to an If statement and this confuses me most. This seems like it should work since the statement is outputting true and the code in the braces works stand alone.

PS C:\Users\flatbe> #Requires -RunAsAdministrator
>> $IPAddress = (Get-NetIPAddress -AddressFamily IPV4 -InterfaceIndex 21).IPAddress
>> write-output $IPAddress
>> Write-output if($IpAddress -match "169"){
>>  Get-NetIPConfiguration | ? InterfaceAlias -match "wi" | Restart-Netadapter}
169.254.182.44
if
True

Get-NetIPConfiguration | ? InterfaceAlias -match "wi" | Restart-Netadapter

Barrington
  • 15
  • 4

1 Answers1

0

So this script works to temporarily fix my problem. If anyone knows why the link local assignment might be getting generated please let me know here. This script is helping dramatically.

    $IPAddress = (Get-NetIPAddress -AddressFamily IPV4 -InterfaceAlias Ethernet).IPAddress

write-output $IPAddress

if($IpAddress -match "169"){

try { Get-NetIPConfiguration | Where-Object InterfaceAlias -match "Ethernet" | Restart-Netadapter



}

catch {

    Write-Output "An Error Occurred"

}

}

I trigger this on log in to the Skype profile on the MTR NUC, I only allow it to run once. that way if we are able to enable dhcp later on this wont sit there bumping a NIC with a 169 octet over and over again forever.

Barrington
  • 15
  • 4