Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell -Replace with wildcards

$
0
0

Hi all,

I want to write a powershell script that updates only part of a UNC path. The path may vary and the last directory in the unc always starts with the same name but has a different 3 letter code. For example:

\\server1\dir1\dir2\dir3\oldfolder-ABC

\\server2\dir6\oldfolder-DEF

So logically what I (think I) need to do is replace all of the text before and including "oldfolder_###" with the new UNC path

something like...

$newPath = $oldPath -replace ([regex]::Escape("*oldfolder-___")),"\\newserver\newfolder"

But that obviously doesn't work :) Can anyone help pls?

Many thanks


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>