Tip / Trick of the week

Use this PowerShell script to replace a string in all files in a directory. This can be helpful when moving applications from one server to another, or changing server names. The ” | Where-Object { $_.Name -like “*.” }” can be dropped if you aren’t looking for a particular file type. Be sure to match the output file encoding.

$files = (get-childitem -recurse | Where-Object { $_.Name -like “*.” }).fullname

ForEach ( $file in $files ) {

(get-content $file).replace(”,”) | out-file $file -encoding ASCII

}

Share:

Facebook
Twitter
LinkedIn
Picture of Matt Tinney

Matt Tinney

Professional IT executive & business leader having decades of experience with Microsoft technologies delivering modern-day cloud & security solutions.

Contact Us

=
On Key

More Posts

WME Cybersecurity Briefings No. 024
Cyber Security

WME Security Briefing 28 August 2024

GhostWrite Vulnerability in T-Head CPUs Exposes Devices to Unrestricted Access Overview A critical architectural flaw in T-Head’s XuanTie C910 and C920 RISC-V CPUs was uncovered by recent research from the CISPA Helmholtz Center for Information Security. Dubbed GhostWrite, the vulnerability

Click Here to Read Full Article »
Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.

=