You haven't stored the output from the "ConvertTo-HTML . . . -fragment" anywhere. You want to use that output in the second ConvertTo-HTML on line #75 in your script.
This should work:
$Header = @"
<style>
h1 {
font-family: Arial, Helvetica, sans-serif;
color: #000099;
font-size: 28px;
}
h2 {
font-family: Arial, Helvetica, sans-serif;
color: #000099;
font-size: 16px;
}
table {
font-size: 12px;
border: 0px;
font-family: Arial, Helvetica, sans-serif;
}
td {
padding: 4px;
margin: 0px;
border: 0;
}
th {
background: #395870;
background: linear-gradient(#49708f, #293f50);
color: #fff;
font-size: 11px;
text-transform: uppercase;
padding: 10px 15px;
vertical-align: middle;
}
tbody tr:nth-child(even) {
background: #f0f0f2;
}
#CreationDate {
font-family: Arial, Helvetica, sans-serif;
color: #ff3300;
font-size: 12px;
}
</style>
"@
$RaportTitel = "<h1>Rechten </h1>"
$AanmaakDatum = "<p>Aanmaak Datum: $(Get-Date -format yyyy-MM-dd)</p>"
$SearchBase = "OU=,OU=,OU=,DC=,DC="
$Results = Get-ADGroup -Filter * -SearchBase $Searchbase -Properties Name, members |
ForEach-Object {
$GroupName = $_.Name
Get-ADGroupMember -Identity $_ |
ForEach-Object {
[pscustomobject]@{
GroupName = $GroupName
Name = $_.Name
}
}
}
$Table = $Results | ConvertTo-Html -Property GroupName, Name -fragment -PreContent "<h2>test</h2>"
$Report = ConvertTo-Html -Body "$RaportTitel $AanmaakDatum $Table" -Title $RaportTitel -Head $Header
$Report | Out-File "Pathl"