fireguy1125
asked on
Convert CSV to HTML in PowerShell
I would like to have this script output the contents to an html file, is this possible, or would another script need to be created to perform this? The contents of this script is:
I would like the format of the table to be similar to this Picture
Thank you.
compare-object (import-csv Export.CSV | sort) (import-csv Exportold.CSV | sort) -passthru -property Mailbox,User,'$_.AccessRights',IsValid |
% { $obj = $null } {
if ($obj -and $obj.mailbox -eq $_.mailbox)
{
if ($_.SideIndicator -eq '<=') {
$obj.NewUser = $_.User
$obj.NewAccessRights = $_.'$_.AccessRights'
$obj.NewIsValid = $_.IsValid
} else {
$obj.OldUser = $_.User
$obj.OldAccessRights = $_.'$_.AccessRights'
$obj.OldIsValid = $_.IsValid
}
} else {
if ($obj) { Write-Output $obj }
$obj = New-Object PSObject -Property @{
Mailbox = $_.Mailbox
NewUser = $_.User * ($_.SideIndicator -eq '<=')
NewAccessRights = $_.'$_.AccessRights' * ($_.SideIndicator -eq '<=')
NewIsValid = $_.IsValid * ($_.SideIndicator -eq '<=')
OldUser = $_.User * ($_.SideIndicator -eq '=>')
OldAccessRights = $_.'$_.AccessRights' * ($_.SideIndicator -eq '=>')
OldIsValid = $_.IsValid * ($_.SideIndicator -eq '=>')
}
}
} {$obj} | select Mailbox, oldUser, OldAccessRights, OldIsValid, newUser, newAccessRights, newIsValid | Export-Csv -NoTypeInformation Difference.csv
I would like the format of the table to be similar to this Picture
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.