Link to home
Create AccountLog in
Avatar of Bob
BobFlag 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

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Bob

ASKER

Thank you very much, that worked!