need to run command against multiple lines in file that start with ica-tcp

Posted by Nick Parsells on Super User See other posts from Super User or by Nick Parsells
Published on 2014-06-09T15:25:00Z Indexed on 2014/06/09 15:30 UTC
Read the original article Hit count: 320

Filed under:

I want to run a command on each line of a file I have, however its a bit more complicated then I originally thought.

The file contents look like this typically; however there are sometimes more connections:

SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE 
services                                    0  Disc                        
console                                     1  Conn                        
                  t-rpal                   48  Disc                        
ica-tcp#0         bpofiretest              50  Active  wdica               
rdp-tcp#2         a-nparsells              51  Active  rdpwd               
ica-tcp                                 65536  Listen                      
rdp-tcp                                 65537  Listen            

The command I want to run is reset session ica-tcp#0. I also want to run the same command on any additional connections that start with ica-tcp that the scripts finds in the file.

How can I write a script like that in powershell?

thanks!

© Super User or respective owner

Related posts about powershell