Public/Wifi/Get-WiFiAvailableAdapter.ps1

Function Get-WiFiAvailableAdapter {
  <#
.SYNOPSIS
    Retrieves a list of available Wi-Fi adapters on the system.
 
.DESCRIPTION
    This function checks for Wi-Fi adapters on the system by requesting the necessary
    location permission. If permission is granted, it attempts to fetch a list of available
    Wi-Fi adapters using the `FindAllAdaptersAsync` method. A timeout value can be specified
    for the operation.
 
.PARAMETER TimeoutMs
    Optional. The timeout duration (in milliseconds) for fetching the Wi-Fi adapters.
    Defaults to 10,000 milliseconds (10 seconds).
 
.EXAMPLE
    Get-WiFiAvailableAdapter
    Retrieves all available Wi-Fi adapters within the default timeout.
 
.EXAMPLE
    Get-WiFiAvailableAdapter -TimeoutMs 5000
    Retrieves all available Wi-Fi adapters with a 5-second timeout.
#>

  [outputtype([Windows.Devices.WiFi.WiFiAdapter])]
  param(
    [int]$TimeoutMs = 10000
  )
  Process {
    if ( (Request-LocationPermission) -ne [Windows.Devices.Geolocation.GeolocationAccessStatus]::Allowed) { Write-Warning "WiFi-informatie can not be retrieved without locatie-Access."; return } 
    Await -WinRtTask ([Windows.Devices.WiFi.WiFiAdapter]::FindAllAdaptersAsync()) -ResultType ([System.Collections.Generic.IReadOnlyList[Windows.Devices.WiFi.WiFiAdapter]]) -TimeoutMs $TimeoutMs
  }
}