How filter powershell stdout

  ansible, powershell, stdout, windows

Ansible: 2.9
PowerShell: 5
OS: w2k16 Server

Hi all!

I search the method to filter the stdout of Format-Hex from PowerShell launched by ansible.

code:

win_shell: |
 Format-Hex C:test.txt
register: recorder


debug:
  msg: {{ recorder }}

I see:

            0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F

00000000   42 4D 5E 00 00 00 00 00 00 00 36 00 00 00 28 00  BM^.......6...(. 
00000010   00 00 0A 00 00 00 01 00 00 00 01 00 20 00 00 00  ............ ... 
00000020   00 00 00 00 00 00 C4 0E 00 00 C4 0E 00 00 00 00  ......Ä...Ä..... 
00000030   00 00 00 00 00 00 B7 59 71 FF B7 59 71 FF B7 59  ......•Yq.•Yq.•Y 
00000040   71 FF B7 59 71 FF B7 59 71 FF B7 59 71 FF B7 59  q.•Yq.•Yq.•Yq.•Y 
00000050   71 FF B7 59 71 FF B7 59 71 FF B7 59 71 FF        q.•Yq.•Yq.•Yq.

But I only desire:

the all lines contained Hexa data:

42 4D 5E 00 00 00 00 00 00 00 36 00 00 00 28 00
...
...

Thanks again!

Source: Windows Questions

LEAVE A COMMENT