How do I pass the % in echo?

Viewed 33

This is the project

echo (netsh wlan show profiles) ^| Select-String "\:(.+)$" ^| %{$name=$_.Matches.Groups[1].Value.Trim(); $_} ^| %{(netsh wlan show profile name="$name" key=clear)}  ^| Select-String "Key Content\W+\:(.+)$" ^| %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} ^| %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} ^| Format-Table -AutoSize ^>^> "Wifi.txt" >> find.txt

The result is supposed to be like this

(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize >> "Wifi.txt"    

But the result came like this

(netsh wlan show profiles) | Select-String "\:(.+)$" | {(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | {[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize >> "Wifi.txt" 

The sentences that are supposed to appear in the result

%{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %

and

%{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %

I think the problem with the % sign. But if this is true,

how do I pass this tag % in the echo?

0 Answers
Related