

GC with Filter / Include / Exclude parameter. Get-Content D:\Temp\stream1.txt -Stream $stream2 Set-Content D:\Temp\stream1.txt -Value "This is the new line" . When new content is added with the new stream in the same file then it can be recognized easily. The above command will keep the existing content in the stream1. Get-Content D:\Temp\stream1.txt -Stream $stream1 You can select another formatting as mentioned above in parameter explanation. Here, encoding Byte is selected so the data will be in byte format. Get-Content D:\Temp\testreadC.txt -Encoding Byte -TotalCount 10 The above command will store the entire file content into a single string instead of an array. GC with above command will split the file content with character and start a new line after it. The above example will send 10 lines at a time to new file ReadC.txt. Get-Content -Path D:\Temp\testreadC.txt -ReadCount 10 | Set-Content D:\Temp\ReadC.txt Get-Content -Path D:\Temp\testreadC.txt -Tail 10Ī total of 10 lines will be displayed from the bottom. Get-Content -Path D:\Temp\testreadC.txt -TotalCount 10Ī total of 10 lines will be displayed from the beginning. In the testreadC.txt file, we have stored processes. The examples of the PowerShell Get-Content is given below: Verbose,Debug, ErrorAction, ErrorVariable, WarningAction, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. CommonParameters: Below common parameters are used which are also called advance function’s parameters.If your path includes any escape characters then mark them under a single quote and PowerShell will consider it as a single path. Unlike -path parameter, you cannot specify wildcard characters here because this parameter can’t interpret characters as wildcards. LiteralPath: This parameter specifies the path of one or more locations.Once you create a different stream, you can retrieve changes in the files according to the stream. Stream: This parameter is used to create the stream.AsByteStream: This parameter was introduced in PowerShell 6.0 and specifies if the contents should be read as a byte of the stream.Encoding: Specifies the type of encoding for the target file.

Raw: Returns the multiple lines as a single string but preserves the new lines in the output.The wait cannot be combined with Raw Parameter.

In the second case, there will be a non-terminating error.
