PowerShell is not limited to cmdlets and can run executables. For example, there is no built-in cmdlet to list the existing Wi-Fi profiles, but netsh.exe can provide the information:

 
PS> netsh wlan show profiles
 

Use Select-String to identify only output lines that match the pattern (a colon with following text), then use the -split operator to separate the strings at “: “, and get just the profile names by returning the last array element (index -1):

 
PS> netsh wlan show profiles | 
      Select-String ":(.{1,})$" | 
      ForEach-Object { ($_.Line -split ': ')[-1] }
 




Twitter This Tip! ReTweet this Tip!

Anonymous