Passing values to parameters from file in Powershell

Suppose you want to see the processes with name – chrome and explorer. You can use below command for that.

Get-Process  -name chrome, explorer

Sometimes it is not practical to pass all values from  the command line. In such scenarios, we can pass values to the parameters from file using below syntax.

Get-Process  -name (Get-Content myfile.txt)

Note that “myfile.txt” should contains the parameter values (names of processes) separated by new line character.





You may also like...