I am capturing TCP packets using a Wireshark tool, TShark.exe. See below code example:
cd 'c:\program files\WireShark\'
.\tshark.exe -c 10
Capturing on 'Ethernet0'
1 0.000000 192.168.1.0 -> 192.168.2.0 TCP 60 49188 -> 445 [ACK]
1 0.000198 192.168.1.0 -> 22.14.2.0 TCP 60 53144 -> 3389 [ACK]
All ok so far, but now if storing in a variable:
$packets = .\tshark.exe -c 10
$packets
1 0.000000 192.168.1.0 ÅÖ% 192.168.2.0 TCP 60 49188 ÅÖ% 445 [ACK]
The directional arrows are lost and replaced with rogue characters. How can I preserve the formatting when storing in a variable?
$packets = .\tshark.exe -c 10 | Out-String
? – Sidneysidomachcp 65001
and see if that fixes it (it did for me...)? If it does, have a read of this answer here: https://mcmap.net/q/1328984/-powershell-and-german-umlauts-in-git-branch-names for what it's doing... – Eyehole