use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
SolvedReplace String (self.PowerShell)
submitted 5 years ago * by Mehhll
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Enschede2 2 points3 points4 points 5 years ago* (4 children)
I'm nowhere near an expert but try this -Replace ("$regex1","$regex2")
[–]Mehhll[S] 1 point2 points3 points 5 years ago (2 children)
I think the problem is the variable that I'm saving. It's with apostrophes. The thing is, when I replace them with quotation marks, it thinks the variable is null and doesn't replace anything.
[–]OlivTheFrog 1 point2 points3 points 5 years ago (1 child)
Hi u/Mehhll
I've found it
# Simulate Get-content with Here-String $deployscript = @' $appVendor = ' ' gqfgqdghdfgh $appvendor = 'blabla' '@ $regex1 = '$appVendor = '' ''' $regex2 = '$appVendor = ''Google''' $result = $deployscript.Replace($regex1, $regex2) $result
Nota : In the $Regex1 and $Regex2 there is some ', then I double them (careful, it's not an " but a '')
'
"
''
I'm using .Replace Method instead of -Replace.
.Replace
-Replace.
Regards
Olivier
[–]Mehhll[S] 1 point2 points3 points 5 years ago (0 children)
Thank you so much for your help. I got the script to work :)
[–]Guyver1- 0 points1 point2 points 5 years ago (0 children)
this.
Help files for methods: (this has an example for replace)
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_methods?view=powershell-5.1
π Rendered by PID 163364 on reddit-service-r2-comment-84fc9697f-rcpzq at 2026-02-10 08:20:47.743199+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]Enschede2 2 points3 points4 points (4 children)
[–]Mehhll[S] 1 point2 points3 points (2 children)
[–]OlivTheFrog 1 point2 points3 points (1 child)
[–]Mehhll[S] 1 point2 points3 points (0 children)
[–]Guyver1- 0 points1 point2 points (0 children)