troubleshooting Question

PowerShell -replace

Avatar of Bob
BobFlag for United States of America asked on
Powershell
2 Comments1 Solution98 ViewsLast Modified:
I am attempting to replace part of a string and replace it with another.

Here is my string:
2/6/2020 3:46:22 PM - Server Name                              =>HHHHHHHHHAA01.nidy.state.xx.us
I want to replace, "2/6/2020 3:46:22 PM - Server Name" with "Server Name"

Below is what I have so far and I stuck

$replace_space = Get-Content C:\Temp\Environment_Verification_NGDI\UAT27_a.txt -Encoding Ascii
$replace_space -replace '(?<=Server Name=").*?(?=")','Server Name' | Set-Content C:\Temp\Environment_Verification_NGDI\UATxx_b.txt
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros