'How do I detect if certain SSID is available or not?

I have the following command that will list the available SSIDs. I'd like to have a small script that execute if a specific one of them is detected.

PS C:\Users\User> $Networks = (netsh wlan show networks mode=Bssid | ?{$_ -like "SSID*"})
>>
SSID 1 : Home
SSID 2 : Guest
SSID 3 : i-Phone

Example:


$result = For($i = 0;$i -lt $Networks.count)
{
# parse through networks here? 
}

 $SSID = "i-Phone"
 if ( $Networks.contains($SSID))
 {
    return $TRUE
 }
 else
 {
      return $FALSE
 }


Solution 1:[1]

Using one of the suggested comments below and just splitting and trimming the string this has worked as needed:

$Network = (netsh wlan show networks mode=Bssid | ?{$_ -like "SSID*$SSID"}).split(':')[1].trim()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JakobyScream