Files

Another area where you should become very confident is working with files, as you will need to work with them very frequently. First, we will take a look at the basics of working with files by retrieving and writing files and the content of the files. This can be achieved with the Get-Content and Set-Content/Out-File cmdlets.

First of all, we will take a dedicated look at how you can export content to a file:

#Storing working location$exportedProcessesPath = 'C:\temp\exportedProcesses.txt'#Write processes table to file and show the result in Terminal with the -PassThru flagGet-Process | Set-Content -Path $exportedProcessesPath #Open file to verifypsedit $exportedProcessesPath#retrieving processes and exporting them to fileGet-Process ...

Get Learn PowerShell Core 6.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.