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
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
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


