ConvertTo-html using powershell

Viewed 41

I have a list of string data .. I generate a csv file and it works but when I need to generate as html report its not working ..

# Unpack Access Token
$token = ($tokenRequest.Content | ConvertFrom-Json).access_token

$SetDate = Get-Date($SetDate) -format yyyy-MM-dd

$GraphSignInLogs  = "https://graph.microsoft.com/v1.0/auditLogs/signIns" 

$result = (Invoke-RestMethod -Uri $GraphSignInLogs -Headers $Headers -Method Get)

$alluserhistory = @()

foreach ($resitem in $result){
    $userhistory = New-Object psobject -Property @{
        User         = $resitem.userDisplayName 
        UPN          = $resitem.userPrincipalName 
        AzureAppUsed = $resitem.appDisplayName 
        UserApp      = $resitem.clientAppUsed 
        IP           = $resitem.ipAddress 
        Date         = $resitem.createdDateTime 
        OS           = ($resitem.deviceDetail).operatingSystem 
        browser      = ($resitem.deviceDetail).browser 
        City         = ($resitem.location).city 
        Country      = ($resitem.location).countryOrRegion 
        CompanyName  = $resitem.companyName 
    }

  $alluserhistory += $userhistory
}

$alluserhistory|
    Select-Object User, UPN, AzureAppUsed |
    ConvertTo-html  -As TABLE |
    Out-File "Desktop/3.html"

it output only the main titles without data is there any way I can generate html file?

0 Answers
Related