Use the Out-File
cmdlet
Compare-Object ... | Out-File C:\filename.txt
Optionally, add -Encoding utf8
to Out-File
as the default encoding is not really ideal for many uses.
More Related Contents:
- Output (“echo”) a variable to a text file
- Writing console output to a file – file is unexpectedly empty
- this code my teacher gave it to us as homework and it does not work with me idk why
- Get-Aduser -Filter will not accept a variable
- In what scenario was Invoke-Expression designed to be used?
- Powershell executable isn’t outputting to STDOUT
- How can I write/create a powershell script verbatim, from another powershell script?
- How do I pass variables with the Invoke-Command cmdlet?
- How to remove all quotations mark in the csv file using powershell script?
- Set-Content appends a newline (line break, CRLF) at the end of my file
- Progress during large file copy (Copy-Item & Write-Progress?)
- How to get started with PowerShell? [closed]
- How to export data to CSV in PowerShell?
- How to convert to UInt64 from a string in Powershell? String-to-number conversion
- How to process a file in PowerShell line-by-line as a stream
- Waiting for user input with a timeout
- How to unzip a file in Powershell?
- Echo equivalent in PowerShell for script testing
- Why is an empty PowerShell pipeline not the same as null?
- PowerShell script to check the status of a URL
- Accessing Windows Credential Manager from PowerShell
- Out-FINcodedCommand.ps1 is not recognized – executing a script in the current directory
- Executing powershell command directly in jenkins pipeline
- How to download the SSL certificate from a website using PowerShell?
- Rename file on FTP with PowerShell
- How can I redirect stdout and stderr without polluting PowerShell error output
- Can’t install nuget package because of “Failed to initialize the PowerShell host”
- How to run powershell command in batch file
- Is there a PowerShell equivalent of `paste` (i.e., horizontal file concatenation)? [duplicate]
- Prevent trailing newline in PowerShell Out-File command