Powershell Select-String print between text

Filip 831 Reputation points
2021-03-30T10:04:08.493+00:00

Hello everybody.
I want do something special. This is command which i use in powershell:
netsh wlan show all | Select-String "SSID", "Signal"

But is there way that i can print the string and before will be print next mach i want write my own text.
Explain:

SSID:
Signal:
My text
SSID:
Signal:
My text
...

Thanks for answare

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,621 questions
No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 18,351 Reputation points Microsoft Employee
    2021-03-30T12:05:11.47+00:00

    Hi,

    You can try someting like this.

    netsh wlan show all | ForEach-Object {  
        Select-String -InputObject $_ -Pattern "SSID", "Signal"  
        if($_ -like "*Signal*"){  
            Write-Host 'My text'  
        }  
    }  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful