2

How would I insert variables in the html code i have stored in the variables? What I try it with a $ in the front, it does not detect it. I may be going about this all wrong so any tips are greatly appreciated.

    $myvariable = "string"

$header = 
@"
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">
    <title>System Report</title>
    <style>
    body {
        padding-top: 50px;
      }
      .starter-template {
        padding: 40px 15px;
        text-align: center;
      }
    </style>
  </head>
"@
$myevents = Get-EventLog -EntryType error -LogName application -Newest 25| Select-Object eventid,message,TimeGenerated


$myevents | ConvertTo-Html -Head $header -PreContent $body -PostContent $endhtml -CssUri C:\powershell\bootstrap.css > testing.html
    invoke-item testing.html

1 Answer 1

2

Inside whatever HTML tag you want to add your value, you can include it as $($myvariable).

Ex.

<body>$($myvariable)</body>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.