Remove string from string in PowerShell

Learn how to simply remove a string from another string!

John Savill

May 21, 2017

1 Min Read
Remove string from string in PowerShell

For more technical explainers on PowerShell, read our updated 2021 report: PowerShell 101: A Technical Explainer for IT Pros.

Q. How can I easily remove a string of text in PowerShell?

A. A simple way to remove a string from a string is to search for the string to be replaced and substitute with a blank string. For example to remove LAB I could use:

$LabShortName = $Lab.Name.Replace("LAB","")

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like