Here is a starter.
This is what your code look like when some small attempt is made to make it readable:
Get-VM |
Get-Snapshot |
ForEach-Object{
$snapEvent=Get-VIEvent -Entity $_.VM -Types Info -Finish $_.Created -MaxSamples 1 |
Where-Object{$_.FullFormattedMessage -imatch 'Task: Create virtual machine snapshot'}0
if($snapevent){
Write-Host ( "VM: "+ $snap.VM + ". Snapshot '" + $snap + "' created on " + $snap.Created.DateTime + " by " + $snapevent.UserName +".")
}else{
Write-Host ("VM: "+ $snap.VM + ". Snapshot '" + $snap + "' created on " + $snap.Created.DateTime + ". This event is not in vCenter events database")
}
}
To start with you need to output objects in order to generate HTML. Take all of you write statements and convert them to custom objects. then you can use Convert.
Part of you problem is in assuming that what you have can actually easily be turned into HTML. If you use this as a learning tool you will understand why your initial post was not just a simple question. It shows that you do not know the basics.
You must make the effort to learn the basics on your own. You can ask questions about things you do not understand.
You are also going to have to fix the logic and design errors in your initial script before you can generate objects.