question

Filip-2434 avatar image
0 Votes"
Filip-2434 asked Filip-2434 commented

Powershell Select-String print between text

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered Filip-2434 commented

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks :)

0 Votes 0 ·