Command Needed for copy some content word from one file to another file

Hi All,

Could any one share code for the below scenario

I have a file with some information, I would copy some content work from that file to another file like all the services status stored in a file and need to copy which one was stopped status from that file and copy those stopped services to paste a new file with new name,

Thanks,

Nagaraj,

 

 

[pre]

Get-Service | Out-File C:\Windows\Temp\Services.txt
Get-Content -Path C:\Windows\Temp\Services.txt | Select-String -Pattern “Stopped” | Out-File C:\Windows\Temp\StoppedServices.txt

[/pre]

Rather than parse a file with service state, assuming these are Windows services, you should use Get-Service where you can directly filter the results. Take a look at example 5.

If you are still set on parsing the file, then you need to look at Get-Content and Select-String. If you do some searching, you’ll find examples for just about anything that should help you parse a file with Powershell. When you need help with errors or something not working as expected, post your code, file examples, etc., but do not assume someone will write the script for you.

Thanks Kiran

I am beginner for this area so that but yeah going forward i will try to get something myself only,

thanks Rob,