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

Wildcards in "-replace" operation

$
0
0

Hi there,

maybe someone here can help me.
I've following code and my problem is that the "*" in the 3rd row isn't identified as a wildcard.

$name = ([wmi]"win32_userAccount.Domain='$env:userdomain',Name='$env:username'").fullname

$xcu = get-content $env:userprofile\AppData\Roaming\OpenOffice.org\3\user\registrymodifications.xcu

$xcu = $xcu -Replace("<prop oor:name=`"givenname`" oor:op=`"fuse`"><value>*</value>","<prop oor:name=`"givenname`" oor:op=`"fuse`"><value>$name</value>")

If I use a specific text instead of the wildcard the script is working fine.
Is it possible to tell Powershell that this should be a wildcard?

Thank You!

Best,
Michael


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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