15.2. Writing Content

As we already mentioned, Get-Content has a symmetric cmdlet that performs the opposite action. It is called Set-Content, and it takes two parameters: -Value, which contains the object to be written to the file, and -Path, which holds the path to the file. The -Value parameter can be taken from the input pipeline instead of being specified explicitly. I have mentioned that it contains the object to be written to the file; this can be any object or a collection. If you pass an object, its built-in ToString() method will be called to get the string representation that will be stored to the file. If you pass a collection, it will be enumerated and all its members will be treated in manner that applies for a single object. To ...

Get Pro Windows PowerShell 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.