Avatar of Bob
Bob
Flag for United States of America asked on

PowerShell -replace

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

Open in new window

Powershell

Avatar of undefined
Last Comment
Bob

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Bob

ASKER
Thank you very much, that worked!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck