hello all,
My initial goal was to retrieve a set of specific strings (virtual machine names) out of txt file.
Because I wanted only the VM name, I used the -replace operator to remove the unnecessary string (“Display Name:”) in a calculated property.
Thus, my final command would be:
get-content vm-process.txt | select-string “Display Name:” | Select @{l=‘VM Name’; e={$_.line -replace 'Display Name: ‘,’ ’ }} | sort -Property ‘VM Name’
Whilst my output (shown below) is the anticipated, I would like to polish it by eliminating this which space prior to each ‘vmnumber’. Any ideas? if there is a “faster” way to do it is also welcome.
VM Name ------- vmnumber1 vmnumber2 vmnumber3 vmnumber4 vmnumber5 vmnumber6