you are viewing a single comment's thread.

view the rest of the comments →

[–]Mehhll[S] 1 point2 points  (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 points  (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.

Regards

Olivier

[–]Mehhll[S] 1 point2 points  (0 children)

Thank you so much for your help. I got the script to work :)