Suppose you want to write that in the same file, you can do as follows:
Set-Content -Path "C:\temp\Newtext.txt" -Value (get-content -Path "c:\Temp\Newtext.txt" | Select-String -Pattern 'H\|159' -NotMatch)
More Related Contents:
- Delete files older than 15 days using PowerShell
- Powershell script to see currently logged in users (domain and machine) + status (active, idle, away)
- Powershell – Reboot and Continue Script
- PowerShell is missing the terminator: “
- List of all colors available for PowerShell?
- Get-Aduser -Filter will not accept a variable
- How to load assemblies in PowerShell?
- How to get disk capacity and free space of remote computer
- Recursive file search using PowerShell
- Executing an EXE file using a PowerShell script
- How do I get only directories using Get-ChildItem?
- Web.Config transforms outside of Microsoft MSBuild?
- copy-item With Alternate Credentials
- PowerShell – Decode System.Security.SecureString to readable password
- How do I concatenate two text files in PowerShell?
- How to get Powershell Invoke-Restmethod to return body of http 500 code response
- Extract the filename from a path
- How to export data to CSV in PowerShell?
- Powershell ConvertTo-json with embedded hashtable
- Comparing array variables in PowerShell
- How Does Member Enumeration Work in PowerShell 3?
- Using Invoke-Command -ScriptBlock on a function with arguments
- PowerShell script to check the status of a URL
- ConvertTo-JSON an array with a single item
- Gracefully stopping in Powershell
- Get-Content -wait not working as described in the documentation
- Check if a file exists or not in Windows PowerShell?
- Difference between PowerShell Console and PowerShell ISE
- List hidden sub-directories and sizes
- Powershell: Set a Scheduled Task to run when user isn’t logged in