Edit HTML and put data stored in $password and then use it without writing it

Multi tool use
Edit HTML and put data stored in $password and then use it without writing it
I find and create template in HTML file and I would like to convert variable.
Example:
$test = 'francker'
(Get-Content C:temppasssword2.html).Replace('$password', '$test') |
Out-File C:check.html
If I put $password
inside of the file, the script will put $test
but I want "francker" because I will save in another file and then send by email.
$password
$test
I want to do this because I would like to send a new password by email.
My template is ready and email function too. I know how to copy file in another place.
Other information I have created GUI with windows form.
Thank you Ansgar Wiechers .I put quote '$password' it's for that does not work .
Also I discover one interesting thing's .
I can change some data inside on this file and then use it without writing it .
That's perfect because .
'$test'
$test
Thank you so much ,I haven't try without quote . It was simple . do you know how to edit without write file ?
– lol lol
Jul 1 at 16:33
You can't modify a file without writing it.
– Ansgar Wiechers
Jul 1 at 16:54
ok Thank you for everything .
– lol lol
Jul 1 at 16:56
That still changes only the variable
$body
in memory - not a file on disk. You can also use the .replace()
method one after the other. No need to insert a foreach inbetween. same applies for the -replace
operator. $body=(Get-Content C:temptest4.htm).replace('`$password',$test).replace('`$user',$user).replace('`$manager',$manager)
But please edit your question to contain additional information.– LotPings
Jul 1 at 19:01
$body
.replace()
-replace
$body=(Get-Content C:temptest4.htm).replace('`$password',$test).replace('`$user',$user).replace('`$manager',$manager)
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
'$test'
->$test
. The single quotes prevent PowerShell from expanding the variable.– Ansgar Wiechers
Jul 1 at 15:58