Example:
I have the following output from a command that detects disks:
/dev/sda -d ata # /dev/sda, ATA device I need to get the first two values - /dev/* and disk type (ata)
In cmd it looks like this:
for /F "tokens=1,3" %%a in ('C:\"Program Files"\smartmontools\bin\smartctl.exe —scan') ^ do echo echo %%a How to do the same in powershell ?
Thank!
PS: I tried to split the line through the split , after pulling the values, it turned out, but there can be a huge number of disks, so this option is no longer necessary, I would like to receive the field numbers.
C:\"Program Files"\smartmontools\bin\smartctl.exe —scan | % {,-split$_} | % {$_[0,2]-join' '}C:\"Program Files"\smartmontools\bin\smartctl.exe —scan | % {,-split$_} | % {$_[0,2]-join' '}- PetSerAl