如何在我存储在变量中的html代码中插入变量?我用前面的$尝试它,它没有检测到它。我可能会认为这一切都是错的,所以我们非常感谢任何提示。
$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
答案 0 :(得分:2)
在您要添加价值的任何HTML代码中,您可以将其包含为$($myvariable)
。
实施例
<body>$($myvariable)</body>