OSDeploy / OSD

OSD Shared Functions
MIT License
132 stars 54 forks source link

Errors in Start-WinREWifi phase, testing wi-fi network adapter #91

Open sultanberisa opened 7 months ago

sultanberisa commented 7 months ago

After Start-WinREWifi in WinPE, in the "test wi-fi network connection" we get several "false" errors due to "Test Wi-Fi Connection" region in OSD.WinRE.WiFi.ps1 file.

if ($WirelessNetworkAdapter.NetEnabled -eq $true) {
    Write-Host -ForegroundColor Green ''
    Write-Warning "Wireless is already connected ... Disconnecting"
    (Get-WmiObject -ClassName Win32_NetworkAdapter | Where-Object {$_.NetConnectionID -eq 'Wi-Fi'}).disable() | Out-Null
    (Get-WmiObject -ClassName Win32_NetworkAdapter | Where-Object {$_.NetConnectionID -eq 'WiFi'}).disable() | Out-Null
    (Get-WmiObject -ClassName Win32_NetworkAdapter | Where-Object {$_.NetConnectionID -eq 'WLAN'}).disable() | Out-Null
    Start-Sleep -Seconds 5
    (Get-WmiObject -ClassName Win32_NetworkAdapter | Where-Object {$_.NetConnectionID -eq 'Wi-Fi'}).enable() | Out-Null
    (Get-WmiObject -ClassName Win32_NetworkAdapter | Where-Object {$_.NetConnectionID -eq 'WiFi'}).enable() | Out-Null
    (Get-WmiObject -ClassName Win32_NetworkAdapter | Where-Object {$_.NetConnectionID -eq 'WLAN'}).enable() | Out-Null
    Start-Sleep -Seconds 5
    $StartWinREWiFi = $true
}
else {
    Write-Host -ForegroundColor Green 'OK'
}

The issue here is that, it finds a match for "Wi-Fi", meaning that the enable and disable lines for "WiFi" (without a dash) and "WLAN" will always return a "cannot call a method on a null-valued expression" for the end user. It's not really user friendly and i'm wondering why this even occurs considering that we are already connected to the Wi-Fi network when this happens.

Any ideas?