Bin/ADSyncDiagnostics/PSScripts/ADSyncDiagnostics.ps1

#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
#-------------------------------------------------------------------------

#
# Event IDs
#
Set-Variable -Option Constant -Scope script -Name EventIdDiagnosticsReportRun  -Value 3001
Set-Variable -Option Constant -Scope script -Name EventIdDiagnosticsReportEnd  -Value 3002
Set-Variable -Option Constant -Scope script -Name EventIdDiagnosticsReportFail -Value 3003

#
# Event Messages
#
Set-Variable -Option Constant -Scope script -Name EventMsgDiagnosticsReportRun  -Value "`r`nData collection has been started."
Set-Variable -Option Constant -Scope script -Name EventMsgDiagnosticsReportEnd  -Value "`r`nData collection finished successfully. `r`n{0}"
Set-Variable -Option Constant -Scope script -Name EventMsgDiagnosticsReportFail -Value "`r`nData collection terminated with an error. `r`n{0}"


#-------------------------------------------------------------------------
#
# Helper functions to run AADConnect Diagnostics Report.
#
#-------------------------------------------------------------------------

#
# Outputs Windows Server OS information
#
Function Get-ADSyncDiagsServerOS
{
    $adSyncServername = $env:computername
    $adSyncOS = Get-WmiObject -class Win32_OperatingSystem -computername $adSyncServername

    $adSyncOSa = @()
    $row = "" | select ComputerName,Description,Caption,Version,BuildNumber,ServicePackMinorVersion,ServicePackMajorVersion,OSLanguage,OSArchitecture,Locale,CodeSet,LastBootUpTime,InstallDate
    $row.ComputerName = $adSyncServername
    $row.Description = $adSyncOS.Description
    $row.Caption = $adSyncOS.Caption
    $row.Version = $adSyncOS.Version
    $row.BuildNumber = $adSyncOS.BuildNumber
    $row.ServicePackMinorVersion = $adSyncOS.ServicePackMinorVersion
    $row.ServicePackMajorVersion = $adSyncOS.ServicePackMajorVersion
    $row.OSArchitecture = $adSyncOS.OSArchitecture
    $row.OSLanguage = $adSyncOS.OSLanguage
    $row.Locale = $adSyncOS.Locale
    $row.CodeSet = $adSyncOS.CodeSet
    $row.LastBootUpTime = $adSyncOS.LastBootUpTime
    $row.InstallDate = $adSyncOS.InstallDate
    $adSyncOSa += $row

    return $adSyncOSa
}

#-------------------------------------------------------------------------
#
# Helper function to initialize AADConnect Diagnostics Report.
#
#-------------------------------------------------------------------------
Function Initialize-ADSyncDiagnosticsPath
{
    param
    (
        [parameter(mandatory=$true)]
        $OutputPath
    )

    if (-not $(Test-Path $OutputPath))
    {
        try 
        {
            $resultFolder = mkdir -Path $OutputPath -ErrorAction Stop
            return $true
        }
        catch       
        {
            $resultMsg = "An error occurred while creating the folder $OutputPath for AADConnect Diagnostics: $($_.Exception.Message)"
            WriteEventLog($EventIdDiagnosticsReportFail)($EventMsgDiagnosticsReportFail -f $resultMsg)
            Write-Error $resultMsg
            return $false
        }
    }
    else
    {
        return $true
    }
}

Function Initialize-ADSyncDiagnosticsText
{
    $Global:ADSyncDiagsTextReport = $null

    $culture = New-Object System.Globalization.CultureInfo 'en-us'
    $dateLocal = $((Get-Date).DateTime).ToString($culture)
    $date = $((Get-Date).ToUniversalTime()).ToString($culture)
    $Global:ADSyncDiagsTextReport = "AAD Connect Diagnostics`r`n"
    $Global:ADSyncDiagsTextReport += "$date (UTC)`r`n"
    $Global:ADSyncDiagsTextReport += "$dateLocal (Local)`r`n"
    $Global:ADSyncDiagsTextReport += "`r`n`r`n`r`n"
}

Function Initialize-ADSyncDiagnosticsHtml
{
    $Global:ADSyncDiagsHtmlReport = $null   
    $Global:ADSyncDiagsHtmlReport = @"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AAD Connect Diagnostics Report</title>
<style>
p{ line-height: 1em; }
h1, h2, h3, h4{
    color: DodgerBlue;
    font-weight: normal;
    line-height: 1.1em;
    margin: 0 0 .5em 0;
}
h1{ font-size: 1.7em; }
h2{ font-size: 1.5em; }
a{
    color: black;
    text-decoration: none;
}
    a:hover,
    a:active{ text-decoration: underline; }
body{
    font-family: arial; font-size: 80%; line-height: 1.2em; width: 100%; margin: 0; background: white;
}
</style>
</head><body>
"@

    $dateUTC = [string] "$((Get-Date).ToUniversalTime().DateTime) (UTC)"
    $dateLocal = [string] "$((Get-Date).DateTime) (Local)"
    $Global:ADSyncDiagsHtmlReport += "<H1>AAD Connect Diagnostics on $($env:computername)</H1>"
    $Global:ADSyncDiagsHtmlReport += "<p>$dateLocal</p>"
    $Global:ADSyncDiagsHtmlReport += "<p>$dateUTC </p>"
}

#-------------------------------------------------------------------------
#
# Helper function to extend content of AADConnect Diagnostics Report.
#
#-------------------------------------------------------------------------
Function Add-ADSyncDiagnosticsText
{
    param
    (
        [parameter(mandatory=$false)]
        $Title,
        [parameter(mandatory=$false)]
        $AppendObject
    )

    if ($Title -ne $null)
    {
        $Global:ADSyncDiagsTextReport += "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" 
        $Global:ADSyncDiagsTextReport += "`r`n"
        $Global:ADSyncDiagsTextReport += $Title
        $Global:ADSyncDiagsTextReport += "`r`n"
        $Global:ADSyncDiagsTextReport += "----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
        $Global:ADSyncDiagsTextReport += "`r`n"
    }
    
    if ($AppendObject -ne $null)
    {
        $Global:ADSyncDiagsTextReport += $AppendObject | Out-String
    }
}

Function Add-ADSyncDiagnosticsHtml
{
    param(
        [parameter(mandatory=$false)]
        $Title,
        [parameter(mandatory=$false)]
        $HeadingSize="H2",
        [parameter(mandatory=$false)]
        $AppendObject,
        [ValidateSet("List","Table","String")]
        $Format="Table"
    )
    
    if ($Title -ne $null)  
    {
        $Global:ADSyncDiagsHtmlReport += "<$HeadingSize>$Title</$HeadingSize>`r`n"
    }
    
    if ($AppendObject -ne "")
    {
        if ($Format -like "String")  
        {
            $Global:ADSyncDiagsHtmlReport += "<p>$AppendObject</p>`r`n"
        }
        else  
        {
            $Global:ADSyncDiagsHtmlReport += $AppendObject | ConvertTo-Html -Fragment -As $Format
        }
        $Global:ADSyncDiagsHtmlReport += "<p></p>`r`n"
    }
} 

#-------------------------------------------------------------------------
#
# Helper function to export AADConnect Diagnostics Report into a file.
#
#-------------------------------------------------------------------------
Function Export-ADSyncDiagnosticsText
{
    param
    (
        [parameter(mandatory=$true)]
        $Title,
        [parameter(mandatory=$true)]
        $ReportDate,
        [parameter(mandatory=$true)]
        $OutputPath
    )

    $filename = "$OutputPath\$($ReportDate)_$Title.log"
    try 
    {
        $Global:ADSyncDiagsTextReport | Out-String | Out-File -FilePath $filename -ErrorAction Stop

        $resultMsg = "AAD Connect Diagnostics Text Report is available at: `n$filename `n" 
        $resultMsg | Write-Host -ForegroundColor Green
    }
    catch  
    {
        $resultMsg = "An error occurred while exporting AADConnect Diagnostics to $filename : $($_.Exception.Message)"
        WriteEventLog($EventIdDiagnosticsReportFail)($EventMsgDiagnosticsReportFail -f $resultMsg)
        Write-Error $resultMsg
    }

    return  $resultMsg
}

Function Export-ADSyncDiagnosticsHtml
{
    param
    (
        [parameter(mandatory=$true)]
        $Title,
        [parameter(mandatory=$true)]
        $ReportDate,
        [parameter(mandatory=$true)]
        $OutputPath
    )
    
    $filename = "$OutputPath\$($ReportDate)_$Title.html"
    
    if ($Global:ADSyncDiagsHtmlReport -ne $null)  
    {
        $Global:ADSyncDiagsHtmlReport += "</body></html>"        
        try 
        {
            $Global:ADSyncDiagsHtmlReport  | Out-String | Out-File -FilePath $filename -ErrorAction Stop
            $resultMsg = "AAD Connect Diagnostics HTML Report is available at: `n$filename `n" 
            $resultMsg | Write-Host -ForegroundColor Green

            "Opening the html report in Internet Explorer..." | Write-Host -fore White
            Write-Host "`r`n"
    
            try
            {
                #
                # Add 'Microsoft.VisualBasic' namespace into PowerShell session.
                #
                Add-Type -AssemblyName "Microsoft.VisualBasic"
        
                $internetExplorer = New-Object -com internetexplorer.application

                $internetExplorer.navigate2($filename)
                $internetExplorer.visible = $true

                if ($internetExplorer.Busy)
                {
                    Sleep -Seconds 15
                }

                $ieProcess = Get-Process | ? { $_.MainWindowHandle -eq $internetExplorer.HWND }

                #
                # Set focus to Internet Explorer so that it will appear on top of other windows.
                #
                [Microsoft.VisualBasic.Interaction]::AppActivate($ieProcess.Id)
            }
            catch
            {
                Write-Error "Unable to open Internet Explorer : $($_.Exception.Message)"
                Write-Host "`r`n"
            }
        }
        catch   
        {
             $resultMsg = "An error occurred while exporting AADConnect Diagnostics to $filename : $($_.Exception.Message)"
             WriteEventLog($EventIdDiagnosticsReportFail)($EventMsgDiagnosticsReportFail -f $resultMsg)
             Write-Error $resultMsg
        }
    }

    return $resultMsg
}

Function Compress-ADSyncDiagnostics
{
    param
    (
        [parameter(mandatory=$true)]
        $Title,
        [parameter(mandatory=$true)]
        $ReportDate,
        [parameter(mandatory=$true)]
        $SourcePath,
        [parameter(mandatory=$true)]
        $OutputPath
    )
    $filename = [string] "$OutputPath\$ReportDate" + "_ADSyncDiagnosticsReport.zip"
    $tempFolder = [string] "$env:temp\$ReportDate" + "_ADSyncDiagnosticsReport"

    # Copy all logs to %Temp% because current 'C:\ProgramData\AADConnect\trace-yyyymmdd-hhmmss.log' is being used by another process
    try  
    {
        Copy-Item $SourcePath $tempFolder -Recurse -ErrorAction Stop
    }
    catch   
    {
        $resultMsg = "Unable to compress AAD Connect Diagnostics information to $filename : $($_.Exception.Message)"
        WriteEventLog($EventIdDiagnosticsReportFail)($EventMsgDiagnosticsReportFail -f $resultMsg)
        Write-Error $resultMsg
        return $resultMsg
    }    

    # Compress AAD Connect Diagnostics folder
    try  
    {
        Add-Type -AssemblyName "System.io.Compression.Filesystem"
        [io.Compression.Zipfile]::CreateFromDirectory($tempFolder, $filename)
        
        $resultMsg = "AADConnect Diagnostics compressed data is available at: `n$filename `n" 
        $resultMsg | Write-Host -ForegroundColor Green
    }
    catch   
    {
        $resultMsg = "Unable to compress AAD Connect Diagnostics information to $filename : $($_.Exception.Message)"
        WriteEventLog($EventIdDiagnosticsReportFail)($EventMsgDiagnosticsReportFail -f $resultMsg)
        Write-Error $resultMsg
    }
    Remove-Item -Path $tempFolder -Recurse -Force
    return $resultMsg
}



#-------------------------------------------------------------------------
#
# Generates a report of AAD Connect Diagnostics including:
# 1- AAD Company Features / Tenant Configuration
# 2- AADConnect Global Settings
# 3- Per Connector Password Hash Sync Status
# 4- Sync Scheduler Settings and Latest Run
#
#-------------------------------------------------------------------------
Function Export-ADSyncDiagnosticsReport 
{
    param
    (
        [parameter(mandatory=$true)]
        $OutputPath 
    )

    $culture = New-Object System.Globalization.CultureInfo 'en-us'
    $reportDate = $(Get-Date -Format yyyyMMdd-HHmmss).ToString($culture)
    $reportFolder = [string] $reportDate + "_ADSyncDiagnosticsReport"
    
    if (-not (Initialize-ADSyncDiagnosticsPath $OutputPath))
    {
        return
    }

    if (-not (Initialize-ADSyncDiagnosticsPath $("$OutputPath\$reportFolder")))
    {
        return
    }

    WriteEventLog($EventIdDiagnosticsReportRun)($EventMsgDiagnosticsReportRun)
    Write-Host "Collecting AAD Connect Diagnostics Information..."
    Write-Host "`r`n"

    Initialize-ADSyncDiagnosticsText
    Initialize-ADSyncDiagnosticsHtml

    # Get Connectors
    $connectors     = Get-ADSyncConnector
    $aadConnectors  = $connectors | Where-Object {$_.SubType -eq "Windows Azure Active Directory (Microsoft)"}
    $adConnectors   = $connectors | Where-Object {$_.ConnectorTypeName -eq "AD"}

    if ($aadConnectors -ne $null -and $adConnectors -ne $null)
    {
        if ($aadConnectors.Count -eq 1)
        {
            # AAD Company Features / Tenant Configuration
            $aadFeatures = Get-ADSyncAADCompanyFeature
            $aadFeaturesPasswordHashSync = $aadFeatures.PasswordHashSync
            Add-ADSyncDiagnosticsText -Title "Azure AD Tenant - Settings" -AppendObject $($aadFeatures | fl)
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Tenant - Settings" -AppendObject $aadFeatures -Format List

            # AADConnect Global Settings
            $globalSettings = Get-ADSyncGlobalSettingsParameter | Select Name,Value | Sort Name
            $globalSettingsPasswordHashSync = [bool] ($globalSettings | Where-Object {$_.Name -eq "Microsoft.OptionalFeature.PasswordHashSync"}).Value
            
            $globalSettings | % { $globalSettingsHt = [ordered]@{} } { $globalSettingsHt[$_.Name] = $_.Value } # Convert to Hashtable
            $globalSettingsObj =  New-Object PSObject -Property $($globalSettingsHt) # Convert to PSObject
            Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Global Settings" -AppendObject $($globalSettingsObj | fl)
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Global Settings" -AppendObject $globalSettingsObj -Format List

            # Sync Scheduler Settings
            Add-ADSyncDiagnosticsText -Title "Azure AD Connect Sync Scheduler - Settings"
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect Sync Scheduler - Settings"

            $syncSchedulerConfig = Get-ADSyncScheduler
            Add-ADSyncDiagnosticsText -AppendObject $($syncSchedulerConfig | fl)
            Add-ADSyncDiagnosticsHtml -AppendObject $syncSchedulerConfig -Format List

            # Sync Scheduler Last Run
            Add-ADSyncDiagnosticsText -Title "Azure AD Connect Sync Scheduler - Last Run"
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect Sync Scheduler - Last Run"

            $syncSchedulerLastRunObj = New-Object PSObject -Property @{
                TimeGenerated   = "N/A"
                MachineName     = "N/A"
                EventID         = "N/A"
                EntryType       = "N/A"
                Source          = "N/A"
                Message         = "N/A"
            }

            $syncSchedulerEvents = Get-EventLog -LogName Application -Source "Directory Synchronization" -InstanceId 904 -After (Get-Date).AddHours(-3) -ErrorAction SilentlyContinue |
                                   where  {$_.Message -like "Scheduler::SchedulerThreadMain : Started*"} |
                                   select TimeGenerated, MachineName, EventID, EntryType, Source, Message -First 1

            if ($syncSchedulerEvents -ne $null)
            {
                $syncSchedulerLastRunObj = $syncSchedulerEvents
            }
            Add-ADSyncDiagnosticsText -AppendObject $($syncSchedulerLastRunObj | fl)
            Add-ADSyncDiagnosticsHtml -AppendObject $syncSchedulerLastRunObj -Format List


            # AAD Connect Connectors List
            Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Connectors"
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Connectors"
            $aadcConnectors = $connectors | Select Name,Type,Identifier,Version,CreationTime,LastModificationTime
            Add-ADSyncDiagnosticsText -AppendObject $($aadcConnectors | fl)
            Add-ADSyncDiagnosticsHtml -AppendObject $aadcConnectors -Format List

            # Azure AD Connect - Connector Statistics
            if (Get-Command Get-ADSyncConnectorStatistics -ErrorAction SilentlyContinue)  
            {
                Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Connector Statistics"
                Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Connector Statistics"
            
                # Get Connector Statistics using cmdlet Get-ADSyncConnectorStatistics
                $connectors | %{
                    $connectorStats = Get-ADSyncConnectorStatistics -ConnectorName $_.Name | select *
                    Add-ADSyncDiagnosticsText -AppendObject $($_.Name)
                    Add-ADSyncDiagnosticsText -AppendObject $($connectorStats | fl)
                    Add-ADSyncDiagnosticsHtml -Title $($_.Name) -HeadingSize "H3" -AppendObject $connectorStats -Format List 
                }
            }

            # AAD Connectivity Parameters
            Add-ADSyncDiagnosticsText -Title "Azure AD Connect - AAD Connector Account"
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - AAD Connector Account"
            $aadConnectivity = $aadConnectors.ConnectivityParameters | Where-Object {$_.Name -like "UserName"}
            $aadConnectivityStr = "Azure AD Synchronization Service Account: $($aadConnectivity.Value)"        
            Add-ADSyncDiagnosticsText -AppendObject $aadConnectivityStr
            Add-ADSyncDiagnosticsHtml -AppendObject $aadConnectivityStr -Format String

            # AD Connectivity Parameters
            Add-ADSyncDiagnosticsText -Title "Azure AD Connect - AD Connector Account(s)"
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - AD Connector Account(s)"
            $adConnectivity = $ADConnectors.ConnectivityParameters | Where-Object {$_.Name -like "forest-login*" -or $_.Name -eq "forest-name"} | select Name,Value
            Add-ADSyncDiagnosticsText -AppendObject $adConnectivity
            Add-ADSyncDiagnosticsHtml -AppendObject $adConnectivity -Format Table

            # AAD Connect Service
            Add-ADSyncDiagnosticsText -Title "Azure AD Connect - ADSync Service"
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - ADSync Service"
            $adSyncService = Get-WmiObject win32_service | Where-Object {$_.Name -eq 'ADSync'} | Select DisplayName,Name,ProcessId,StartName,StartMode,State,Status,SystemName,PathName
            Add-ADSyncDiagnosticsText -AppendObject $($adSyncService | fl)
            Add-ADSyncDiagnosticsHtml -AppendObject $adSyncService -Format List
            
            # Password Hash Sync Status - Per AD Connector
            Add-ADSyncDiagnosticsText -Title "AD Connector Password Hash Sync - Status"
            Add-ADSyncDiagnosticsHtml -Title "AD Connector Password Hash Sync - Status"
            foreach ($adConnector in $adConnectors)
            {
                $adPasswordSyncConfig = Get-ADSyncAADPasswordSyncConfiguration -SourceConnector $adConnector.Name

                # Password Hash Sync Heartbeat Check (Ping Event)
                $pingEvents = Get-EventLog -LogName "Application" -Source "Directory Synchronization" -InstanceId 654 -After (Get-Date).AddHours(-3) -ErrorAction SilentlyContinue | 
                              Where-Object { $_.Message.ToUpperInvariant().Contains($adConnector.Identifier.ToString("D").ToUpperInvariant()) } | 
                              Sort-Object  { $_.TimeWritten } -Descending

                $lastHeartbeatTime = $null

                if ($pingEvents -ne $null)
                {
                    $lastHeartbeatTime = $($pingEvents[0].TimeGenerated)
                }
                else
                {
                    $lastHeartbeatTime = "N/A"
                }

                $pwdSyncStateObj = New-Object PSObject -Property @{
                    SourceConnector     = $($adPasswordSyncConfig.SourceConnector)
                    TargetConnector     = $($adPasswordSyncConfig.TargetConnector)
                    Enabled             = $($adPasswordSyncConfig.Enabled)
                    LatestHeartBeatTime = $lastHeartbeatTime
                } | select SourceConnector, TargetConnector, Enabled, LatestHeartBeatTime

                Add-ADSyncDiagnosticsText -AppendObject $($pwdSyncStateObj | fl)
                Add-ADSyncDiagnosticsHtml -AppendObject $pwdSyncStateObj -Format List
            }


            # Azure AD Connect Password Writeback - Status
            $aadPasswordResetConfig = Get-ADSyncAADPasswordResetConfiguration -Connector $aadConnectors[0].Name
            Add-ADSyncDiagnosticsText -Title "Azure AD Connect Password Writeback - Status" -AppendObject $($pwdSyncStateObj | fl)
            Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect Password Writeback - Status" -AppendObject $pwdSyncStateObj -Format List
        }
        else
        {
            Write-Warning "More than one Azure AD connectors are found."
            return
        }

        # Azure AD Connect - Local Database Parameters
        $adSyncParameters = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ADSync\Parameters | 
            Select Server,SQLInstance,DBName,Path
        Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Local Database Parameters" -AppendObject $($adSyncParameters | fl)
        Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Local Database Parameters" -AppendObject $adSyncParameters -Format List 
            
        if($adSyncParameters.Server -eq "(localdb)")
        {
            # Azure AD Connect - Local Database size

            $pathToDB = "$($adSyncParameters.Path)Data"
            
            if ($adSyncParameters.SQLInstance -ne ".\ADSync")
            {
                $sharedInstanceName = "$($adSyncParameters.SQLInstance.SubString(2))"
                $pathToDB = "$pathToDB\$sharedInstanceName"
            }

            if (Test-Path $pathToDB)   
            {
                $adSyncDatabaseSize = 0
                $adSyncDatabase = Get-ChildItem -Path $pathToDB 

                $adSyncDatabaseSize = ($adSyncDatabase | where Name -eq "ADSync.mdf").Length/1MB
                Add-ADSyncDiagnosticsText -AppendObject "Database size: $("{0:N2}" -f $adSyncDatabaseSize)MB"
                Add-ADSyncDiagnosticsHtml -AppendObject "Database size: $("{0:N2}" -f $adSyncDatabaseSize)MB" -Format String

                if ($adSyncDatabaseSize -gt 7168)  
                {
                    $adSyncDatabasWarning = "WARNING: AAD Connect Database is reaching maximum limit size (10GB) | ADSync.mdf = $("{0:N2}" -f $adSyncDatabaseSize)MB `n"
                    Add-ADSyncDiagnosticsText -Title $adSyncDatabasWarning
                    Add-ADSyncDiagnosticsHtml -Title $adSyncDatabasWarning -HeadingSize "b"
                }      
            }
            else  
            {
                $adSyncDatabaseError = @("ERROR: Could not find Local Database folder.")
                Add-ADSyncDiagnosticsText -Title $adSyncDatabaseError
                Add-ADSyncDiagnosticsHtml -Title $adSyncDatabaseError -HeadingSize "b"
            }
          
        }

        # Azure AD Connect - Windows Server Configuration
        $adSyncOS = Get-ADSyncDiagsServerOS
        Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Windows Server Configuration" -AppendObject $($adSyncOS | fl)
        Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Windows Server Configuration" -AppendObject $adSyncOS -Format List 
    
        # Azure AD Connect - Proxy Settings
        $adSyncSrvProxyIE = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
        Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Proxy Settings" -AppendObject ($adSyncSrvProxyIE |fl)
        Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Proxy Settings" -AppendObject $adSyncSrvProxyIE -Format List 
        
        # Azure AD Connect - Netsh Winhttp Settings
        $adSyncSrvNetsh = netsh winhttp show proxy | Out-String
        Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Netsh Winhttp Settings" -AppendObject ($adSyncSrvNetsh)
        Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Netsh Winhttp Settings" -AppendObject $adSyncSrvNetsh -Format String

        # Azure AD Connect - .Net Framework Installed
        $adSyncSrvDotNet = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" |
            Select-Object -Property Release,Version,InstallPath,TargetVersion
        Add-ADSyncDiagnosticsText -Title "Azure AD Connect - .Net Framework Installed" -AppendObject ($adSyncSrvDotNet |fl)
        Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - .Net Framework Installed" -AppendObject $adSyncSrvDotNet -Format List 

        # Azure AD Connect - Current User WhoAmI
        $adSyncSrvWhoAmI = whoami /all
        Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Current User WhoAmI" -AppendObject $adSyncSrvWhoAmI
        
        # Azure AD Connect - Programs Installed
        $adSyncSrvApplications = Get-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object -Property `
            @{Label="Name"; Expression={if ($_.DisplayName -like "") {$_.PSChildName} else {$_.DisplayName}}}, `
            DisplayVersion, Publisher, `
            @{Label="InstallDate"; Expression={
                if ($_.InstallDate -like "") {$_.InstallDate} else {$date = [int] $_.InstallDate; $date.ToString("0000-00-00")}
            }} | sort Name
        Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Programs Installed" -AppendObject ($adSyncSrvApplications | ft -AutoSize)
        Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Programs Installed" -AppendObject $adSyncSrvApplications -Format Table 
        
        # Azure AD Connect - Windows Updates
        $adSyncHotfixes = Get-Hotfix | Select HotFixID,InstalledOn,Description,InstalledBy  | Sort-Object â€“Descending â€“Property InstalledOn 
        Add-ADSyncDiagnosticsText -Title "Azure AD Connect - Windows Updates" -AppendObject $adSyncHotfixes
        Add-ADSyncDiagnosticsHtml -Title "Azure AD Connect - Windows Updates" -AppendObject $adSyncHotfixes -Format Table 

        # Export Azure AD Connect - Current User WhoAmI
        $adSyncSrvWhoAmI | Out-File $([string] "$OutputPath\$reportFolder\$reportDate" + "_AADConnect-WhoAmI.txt")

        # Export AAD Connect Full Configuration - Useful when used with AADConnectConfigDocumenter
        Get-ADSyncServerConfiguration -Path $([string] "$OutputPath\$reportFolder\$reportDate" + "_AADConnect-ServerConfig")

        # Azure AD Connect - Export Windows Event Logs
        $after = (Get-Date).AddDays(-7).ToString("yyyy-MM-d")
        $query = "/q:*[System[TimeCreated[@SystemTime>='$($after)T00:00:00.000Z']]]"
        $filename = [string] "$OutputPath\$reportFolder\$reportDate" + "_AADConnect-EvtLogsApplication.evtx"
        wevtutil epl Application $filename $query "/ow:true"
        $filename = [string] "$OutputPath\$reportFolder\$reportDate" + "_AADConnect-EvtLogsSystem.evtx"
        wevtutil epl System $filename $query "/ow:true"

        # Phase 1/2 - Exporting AAD Connect Diagnostics Information
        Write-Host "Exporting AAD Connect Diagnostics Information..."
        Write-Host "`r`n"

        $resultTextReport = Export-ADSyncDiagnosticsText -Title "AADConnect_Report" -ReportDate $reportDate -OutputPath $OutputPath
        $resultHtmlReport = Export-ADSyncDiagnosticsHtml -Title "AADConnect_Report" -ReportDate $reportDate -OutputPath $("$OutputPath\$reportFolder")

        # Phase 2/2 - Compress AAD Connect Diagnostics Information
        if ($OutputPath -eq $("$env:ALLUSERSPROFILE\AADConnect"))
        {
            # Compress all information in ProgramData\AADConnect
            Write-Host "Compressing AAD Connect Diagnostics Information..."
            $resultCompressData = Compress-ADSyncDiagnostics -Title "AADConnect_Report" -ReportDate $reportDate -SourcePath $("$env:ALLUSERSPROFILE\AADConnect") -OutputPath "$env:USERPROFILE\Documents"
        }

        $EventMsgDiagnosticsReportResults = [string] $resultTextReport + "`r`n" + $resultHtmlReport + "`r`n" + $resultCompressData
        WriteEventLog($EventIdDiagnosticsReportEnd)($EventMsgDiagnosticsReportEnd -f $EventMsgDiagnosticsReportResults)
        return
    }

    if ($aadConnectors -eq $null)
    {
        Write-Warning "No AAD connectors are found."
    }

    if ($adConnectors -eq $null)
    {
        Write-Warning "No AD connectors are found."
    }
}

# SIG # Begin signature block
# MIInnwYJKoZIhvcNAQcCoIInkDCCJ4wCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBNI02sr/uI24jl
# xzSTwxzZufaex0zsnej98aIK/8eWSaCCDYIwggYAMIID6KADAgECAhMzAAADXJXz
# SFtKBGrPAAAAAANcMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29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