Good afternoon all;
I am attempting to remove multiple entries from the system path for a number of computers. Specifically, c:\program files\pythonx; c:\program files\pythonx\scripts for multiple versions of python.
What I am unable to do is actually parse this information out and re-apply it while keeping the remainder of the paths within the variable itself. As Such, I have gone to what I thought would be a more simple process and exported the path to a text file and then searched the text file for said values. I cannot, regardless of what I try, get the script to output a new file minus the values I want removed. I am sure that it is a problem escaping the space character in the paths but I'm unsure how to proceed. Any help would be very appreciated.
Example code:
$1 = "c:\program files\python310"
$2 = "c:\program files\python310\scripts"
get-content c:\temp\test.txt | where-Object {$_ -notmatch [regex]::Escape($1) -or $_ -notmatch [regex]::Escape($2) }| Set-Content c:\temp\test2.txt
path1 is just outputting the path on separate lines 1 is the first string I want to search for 2 is the second string I want to search for
I have also tried triple quotes in the $1 & $2 variables.