Obs/bin/GMA/Monitoring/Agent/Extensions/MetricsExtension/mdmDataCollection.ps1

<#
.SYNOPSIS
    Powershell script to collect data about Geneva Metrics (AKA MDM, AKA Geneva Hot Path) data publication.
.DESCRIPTION
    This script performs several operations for troubleshooting issues related to MetricsExtension such as:
    - Collection of metric traffic.
    - Collectio of information about the environment such as OS, processes running.
    - Collection of certificates.
    - Collection of logs.
    - Test connection to Frontends where we emit the metrics.
.EXAMPLE
    ./mdmDataCollection.ps1 -SkipAdminCheck -MetricCollectionDurationSec 60 -Table2CsvPath "C:/table2csv.exe"
.EXAMPLE
    ./mdmDataCollection.ps1 -SkipCollectionTsfLogs -SkipCollectionCertificates
.EXAMPLE
    ./mdmDataCollection.ps1 -LogicalDisks "C: D:"
.EXAMPLE
    ./mdmDataCollection.ps1 -MetricCollectionSizeMaxMB 100 -MetricCollectionDurationSec 60 -TimeOutSecondsSearchFiles -1
.EXAMPLE
    ./mdmDataCollection.ps1 -OutputDirectory "C:\dev"
#>


param (
    # If this switch is specified, the output of all commands will be showed in the output.
    [Parameter(Mandatory=$false)]
    [switch]$DebugMdmDataCollection = $false,

    # The arguments passed for the execution of table2csv.exe.
    # Default value: "-tail 150000"
    [Parameter(Mandatory=$false)]
    [string]$Table2CsvParameters = "-tail 150000",

    # It specifies the time we will be spent collecting the traffic of metrics in seconds.
    # Default value: 190
    [Parameter(Mandatory=$false)]
    [int]$MetricCollectionDurationSec = 190,

    # It specifies the maximum size in MB that will be stored from the collection of the metrics.
    # Default value: 500
    [Parameter(Mandatory=$false)]
    [int]$MetricCollectionSizeMaxMB = 500,

    # If this switch is specified, the check of admin permissions will be skipped
    [Parameter(Mandatory=$false)]
    [switch]$SkipAdminCheck = $false,

    # It specifies the path for cpprestutil.exe
    [Parameter(Mandatory=$false)]
    [string]$CppRestUtilPathParam = $null,

    # It specifies the path for table2csv.exe
    [Parameter(Mandatory=$false)]
    [string]$Table2CsvPathParam = $null,

    # The script needs to search files in the environment, this operation can be really long if your disk is not indexed.
    # This parameter allows you to set a TimeOut in the search. If you don't want to have TimeOut, pass the value -1.
    # Default value: 3600
    [Parameter(Mandatory=$false)]
    [int]$TimeOutSecondsSearchFiles = 3600,

    # It specifies the disks where we are going to search the files in the script.
    # Example for only searching in C: and D:, "C: D:". Use a whitespace as separator.
    [Parameter(Mandatory=$false)]
    [string]$LogicalDisksParam = $null,

    # If this switch is specified, the collection of tsf logs will be skipped.
    [Parameter(Mandatory=$false)]
    [switch]$SkipCollectionTsfLogs = $false,

    # If this switch is specified, the collection of certificates will be skipped.
    [Parameter(Mandatory=$false)]
    [switch]$SkipCollectionCertificates = $false,

    # It specifies in which directory the output is going to be stored.
    [Parameter(Mandatory=$false)]
    [string]$OutputDirectory = "..",

    # This is only used for tests purposes, please don't use it
    [Parameter(Mandatory=$false)]
    [switch]$ImportFunctions = $false
)

$ScriptVersion = "Windows-1.10"

$MeFrontendUrls = @(
    "global.prod.microsoftmetrics.com"
    "global.metrics.nsatc.net"
    "azglobal.metrics.nsatc.net"
)

$Ports = @(
    "80"
    "443"
)

$MeStamps = @(
    "https://global.prod.microsoftmetrics.com"
    "https://azglobal-red.prod.microsoftmetrics.com"
    "https://azglobal-black.prod.microsoftmetrics.com"
    "https://global.metrics.nsatc.net"
    "https://azglobal-red.azglobal.metrics.nsatc.net"
    "https://azglobal-black.azglobal.metrics.nsatc.net"
    "https://global.metrics.azure.microsoft.scloud"
    "https://global.metrics.azure.eaglex.ic.gov"
    "https://13.90.249.229"
    "https://40.77.24.27"
    "https://[2a01:111:f100:2000::a83e:33d6]"
    "https://[2603:1030:7::155]"
)

$StampPaths = @(
    "/public/lb-probe"
    "/public/monitoringAccount/MetricTeamInternalMetrics/acls"
)

$ExcludedEnvironmentVariables = @(
    "_NT_SYMBOL_PATH"
)

function Main
{
    Set-UTF8-Encoding

    Confirm-Admin-Permissions

    $mdmDataCollectionOutput = Get-MdmDataCollectionOutput
    $compressedDataOutput = Get-CompressedDataOutput $mdmDataCollectionOutput

    Show-Starting-Message

    Get-Logical-Disks
    $logicalDisks = Get-Content -Path .\LogicalDisks.txt

    $metricsExtensionPath = Get-File-Version "MetricsExtension.Native.exe" ".\MetricsExtensionProcesses.txt" "MetricsExtensionVersions.txt"

    $cppRestUtil = Search-CppRestUtil $metricsExtensionPath

    Test-ME-Stamps $mdmDataCollectionOutput $cppRestUtil

    Get-Etw-Session-And-IfxMetrics-At-Start

    Get-OS-And-Processes-Information

    Get-Local-Time-Information

    Get-Difference-Time-Server-And-Agent $cppRestUtil

    Get-Certificates

    Get-HTTP-Proxy-Configuration

    Get-Environment-Variables

    Get-Open-Sockets-And-Owning-Processes

    Test-Frontend-Urls

    Get-Application-Event-Logs

    Get-Raw-And-Aggregated-Metrics

    $commandLineArguments = Get-Command-Line-Arguments

    Get-Cached-Config $commandLineArguments

    Copy-Autopilot-Logs
    Get-Autopilot-Ini

    $monAgentHostPath = Get-File-Version "MonAgentHost.exe" ".\MonAgentHostProcesses.txt" "MonAgentHostVersions.txt"

    Get-Tsf-Logs $logicalDisks $mdmDataCollectionOutput $monAgentHostPath

    Get-Etw-Session-And-IfxMetrics-At-End

    Compress-Output $compressedDataOutput $mdmDataCollectionOutput

    Show-Ending-Message
}

function Set-UTF8-Encoding
{
    [void](chcp 65001)
}

function Confirm-Admin-Permissions
{
    if ($SkipAdminCheck) {
        Write-Warning "Administrative permissions check skipped due to SkipAdminCheck being set."
    }
    elseif(-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
        [Security.Principal.WindowsBuiltInRole] "Administrator"))
    {
        $errorMessage = "ERROR: This script has to be run with administrative permissions.`n"
        $errorMessage += "If you believe you have received this message due to an error, you can`n"
        $errorMessage += "skip this check by passing the command line parameter SkipAdminCheck."
        Write-Error $errorMessage
        break
    }
}

function Get-MdmDataCollectionOutput
{
    $folderSuffix = [DateTime]::UtcNow.ToString('yyyy_MM_dd_hh_mm_ss')
    $randomNumber = Get-Random
    $mdmDataCollectionOutput = "MdmDataCollectionOutput" + $folderSuffix + "_random_" + $randomNumber

    [void](Remove-Directory-If-It-Exists $mdmDataCollectionOutput)
    [void](mkdir $mdmDataCollectionOutput)
    [void](Set-Location $mdmDataCollectionOutput)

    return $mdmDataCollectionOutput
}

function Get-CompressedDataOutput([String]$mdmDataCollectionOutput)
{
    $compressedDataOutput = $mdmDataCollectionOutput + ".zip"

    return $compressedDataOutput
}

function Remove-Directory-If-It-Exists([String]$directory)
{
    if (Test-Path -Path $directory)
    {
        Write-Output "File $directory already exists deleting it before proceeding..."
        try
        {
            Invoke-Command "Remove-Item -LiteralPath $directory -Force -Recurse"
        }
        catch
        {
            Write-Error "Failed to delete the file ${directory}: $_. Aborting..."
        }
    }
}

function Show-Starting-Message
{
    $date = Get-Date
    Write-Output "Begin - MDM Data Collection Script - $date"
    Write-Output "Script version $ScriptVersion"
    Write-Output "Collecting general information..."
    Write-Output "MdmDataCollection script version $ScriptVersion" > AboutCollectionScript.txt
}

function Get-Logical-Disks
{
    Write-Output "Collecting information about logical disks"

    if (-Not [string]::IsNullOrEmpty($LogicalDisksParam))
    {
        $LogicalDisksParam = $LogicalDisksParam.Replace(" ", "`n")
        $LogicalDisksParam >> LogicalDisks.txt
    }

    else
    {
        $logicalDisks = Get-WmiObject -Class Win32_LogicalDisk

        foreach ($logicalDisk in $logicalDisks)
        {
            $logicalDisk.DeviceID >> LogicalDisks.txt
        }
    }
}

function Get-File-Version([String]$processName, [String]$inputFile, [String]$outputFile)
{
    Write-Host "Searching the process: $processName"
    wmic PROCESS WHERE "(Name='${processName}')" GET ExecutablePath /FORMAT:list | findstr "=" > $inputFile

    if ([String]::IsNullOrWhiteSpace((Get-content $inputFile)))
    {
        Write-Warning "The process $processName is not running"
        "The process $processName is not running" > $inputFile
        return
    }

    foreach ($process in Get-Content -Path $inputFile)
    {
        $executablePath = $process
        $prefix = "ExecutablePath="
        if ($executablePath.StartsWith($prefix))
        {
            $executablePath = $executablePath.Substring($prefix.Length)
        }
        Write-Output "$executablePath" >> $outputFile
        (Get-Item $executablePath).VersionInfo | format-list >> $outputFile
    }

    return $executablePath
}


function Search-CppRestUtil ([String]$metricsExtensionPath)
{
    if ((-Not [string]::IsNullOrEmpty($CppRestUtilPathParam)) -and (Test-Path -Path $CppRestUtilPathParam))
    {
        return $CppRestUtilPathParam
    }

    if (Test-Path -Path "..\CppRestUtil\CppRestUtil.exe")
    {
        return "..\CppRestUtil\CppRestUtil.exe"
    }

    if ($metricsExtensionPath.Contains("MetricsExtension\MetricsExtension.Native.exe"))
    {
        # MetricsExtension NuGet setup
        $possibleLocationCppRestUtil = $metricsExtensionPath.Replace("MetricsExtension\MetricsExtension.Native","CppRestUtil\CppRestUtil")
        if (Test-Path -Path $possibleLocationCppRestUtil)
        {
            return $possibleLocationCppRestUtil
        }

        # Monitoring Agent setup
        $possibleLocationCppRestUtil = $metricsExtensionPath.Replace("MetricsExtension.Native","CppRestUtil")
        if (Test-Path -Path $possibleLocationCppRestUtil)
        {
            return $possibleLocationCppRestUtil
        }
    }

    $warningMessage = "CppRestUtil was not found in the environment. Instead of CppRestUtil, internal Powershell tools will be used."
    $warningMessage += "Check more information in the following link: https://eng.ms/docs/cloud-ai-platform/azure-edge-platform-aep/aep-health-standards/observability/mdm/geneva-metrics-mdm/docs/tsg/customer-side/actions/winhttp-escalation#powershell-way"
    Write-Warning $warningMessage

    return [string]::Empty
}

function Get-Etw-Session-And-IfxMetrics-At-Start
{
    tasklist /M IfxMetrics.dll /FO CSV > ProcessLoadingIfxMetrics_At_Start.csv
    logman NativeMetricsExtension_Provider -ets > MetricsExtensionEtwSessionAtStart.txt
    logman -ets > EtwSessions.txt
}

function Get-OS-And-Processes-Information
{
    Get-WmiObject -Class Win32_OperatingSystem | Select-Object Caption, SystemDrive, Version > OS.txt
    Get-WmiObject -Class Win32_Process | Export-Csv -Path "AllProcesses.csv" -NoTypeInformation
}

function Get-Local-Time-Information
{
    Write-Output "Collecting time from ME client and server"

    Get-Date > DateTimeLocal.txt
    Get-TimeZone > TimeZoneInfo.txt
}

function Get-Difference-Time-Server-And-Agent([String]$cppRestUtil)
{
    if ([string]::IsNullOrEmpty($cppRestUtil))
    {
        Write-Warning "CppRestUtil.exe is not found. MdmDataCollection will not able to check if there is a difference of time between the server and the agent"
        return
    }

    $serverDate = Invoke-Expression "& '$cppRestUtil' https://global.prod.microsoftmetrics.com/public/lb-probe" | findstr /C:"Date"
    $serverDate > DateTimeServer.txt
    $serverDate = $serverDate.TrimStart("Date: ")
    $serverDate = Get-Date -Date "${serverDate}"
    $serverDateUtc = $serverDate.ToUniversalTime()

    $localDateUtc = [DateTime]::UtcNow

    $deltaMinutes = ($localDateUtc - $serverDateUtc).TotalMinutes

    if (($deltaMinutes -ge 1) -OR ($deltaMinutes -le -5))
    {
        "ERROR: There is a difference of ${deltaMinutes} minutes between ME client time and server time." > TimeDifferenceError.txt
        Write-Error "ERROR: There is a difference of ${deltaMinutes} minutes between ME client time and server time."
    }
}

function Get-Certificates
{
    if ($SkipCollectionCertificates)
    {
        Write-Warning "SkipCollectionCertificates has been set, skipping the collection of certificates."
    }
    else
    {
        certutil -silent -v -gmt -store "My" > Certificates_On_LocalMachine_My.txt
        certutil -user -v -gmt -silent -store "My" > Certificates_On_User_My.txt
    }
}

function Get-HTTP-Proxy-Configuration
{
    netsh winhttp dump > WinHttp_Config.txt
}

function Get-Environment-Variables
{
    Get-ChildItem env: | Where-Object -Value $ExcludedEnvironmentVariables -NotIn -Property Name > EnvironmentVariables.txt
}

function Test-ME-Stamps([String]$mdmDataCollectionOutput, [String]$cppRestUtil)
{
    Write-Output "Testing several MetricsExtension global endpoints"
    foreach ($meStamp in $MeStamps)
    {
        foreach ($stampPath in $StampPaths)
        {
            Test-Connection-To-URL $cppRestUtil $meStamp$stampPath >> .\CppRestUtilResults.txt
        }
    }
}

function Get-Open-Sockets-And-Owning-Processes
{
    Write-Output "Listing open sockets and owning processes"
    netstat -abno > ListeningSockets.txt
}

function Test-Frontend-Urls
{
    foreach ($meFrontendUrl in $MeFrontendUrls)
    {
        foreach ($port in $Ports)
        {
            $solvedDNS = Resolve-DnsName -Name $meFrontendUrl
            Write-Output "Running IPv4 against ${meFrontendUrl}:${port}" 1>> GlobalStamp_TCPPing.txt
            Test-NetConnection $solvedDNS.IP4Address -port ${port} -InformationLevel "Detailed" 1>> GlobalStamp_TCPPing.txt 2>&1
            Write-Output "Finished running IPv4 against ${meFrontendUrl}:${port}" 1>> GlobalStamp_TCPPing.txt
            Write-Output "Running IPv6 against ${meFrontendUrl}:${port}" 1>> GlobalStamp_TCPPing.txt
            Test-NetConnection $solvedDNS.IP6Address -port ${port} -InformationLevel "Detailed" 1>> GlobalStamp_TCPPing.txt 2>&1
            Write-Output "Finished running IPv6 against ${meFrontendUrl}:${port}" 1>> GlobalStamp_TCPPing.txt
        }
    }
}

function Get-Application-Event-Logs
{
    Write-Output "Collecting application event logs for Level Error and EventID 1000 happened within last one hour..."
    Write-Output "Collecting application event logs for Level Error and EventID 1000 happened within last one hour..." > ApplicationErrorLog.txt
    wevtutil qe Application /q:"*[System[Level=2 and EventID=1000 and TimeCreated[timediff(@SystemTime) <= 3600000]]]" /f:text /rd:true >> ApplicationErrorLog.txt
}

function Get-Raw-And-Aggregated-Metrics
{
    Set-MdmInputOutputProviders-File
    Write-Output "Collecting raw and aggregated metrics, please wait..."
    Invoke-Command "logman start MdmDataCollection -max ${MetricCollectionSizeMaxMB} -pf mdmInputOutputProviders.txt -o mdmRaw.etl -ets"
    timeout ${MetricCollectionDurationSec} /nobreak
    Invoke-Command "logman stop MdmDataCollection -ets"
    Invoke-Command "Remove-Item mdmInputOutputProviders.txt"

    logman -ets | findstr /i IfxViewerSession > IfxConsumerSessions.txt

    foreach ($ifxConsumerSession in Get-Content -Path .\IfxConsumerSessions.txt)
    {
        Invoke-Command "logman stop $ifxConsumerSession -ets"
    }
}

function Set-MdmInputOutputProviders-File
{
    $content = @(
        "{edc24920-e004-40f6-a8e1-0e6e48f39d84}"
        "{2f23a2a9-0de7-4cb4-a778-fbdf5c1e7372}"
    )
    $pathMdmInputOutputProviders = (Get-Item -Path ".\" -Verbose).FullName | Join-Path -ChildPath 'mdmInputOutputProviders.txt'
    [IO.File]::WriteAllLines($pathMdmInputOutputProviders, $content)
}

function Search-Files-Job([Object[]]$fileNames, [Object[]]$logicalDisks, [String]$outputFile, [String]$currentPath)
{
    $searchFilesFunc = $(Get-Command Search-Files).Definition
    $invokeCommandFunc = $(Get-Command Invoke-Command).Definition
    $scriptBlock =
    {
        param($fileNames, $logicalDisks, $outputFile, $currentPath)

        Set-Location $currentPath
        Invoke-Expression "function Search-Files {$using:searchFilesFunc}"
        Invoke-Expression "function Invoke-Command {$using:invokeCommandFunc}"
        Search-Files -fileNames $fileNames -logicalDisks $logicalDisks -outputFile $outputFile
    }

    $job = Start-Job -ArgumentList $fileNames, $logicalDisks, $outputFile, $currentPath -ScriptBlock $scriptBlock
    $job | Wait-Job -Timeout $TimeOutSecondsSearchFiles

    if ($job.State -ne "Completed")
    {
        Write-Warning "$fileNames were searched but they took more than $TimeOutSecondsSearchFiles seconds, aborting this search..."
    }
}

function Search-Files([Object[]]$fileNames, [Object[]]$logicalDisks, [String]$outputFile)
{
    foreach($logicalDisk in $logicalDisks)
    {
        foreach($fileName in $fileNames)
        {
            try
            {
                Write-Output "cmd /c dir /s/b ${logicalDisk}\${fileName}"
                cmd /c "dir /s/b ${logicalDisk}\${fileName} > lastDir.txt 2>>dirFailures.txt"
            }
            catch
            {
                "ERROR: cmd /c dir /s/b ${logicalDisk}\${fileName} failed: $_"  >> dirFailures.txt
                Write-Error "ERROR: cmd /c dir /s/b ${logicalDisk}\${fileName} failed: $_"
            }
            Invoke-Command "Get-Content .\lastDir.txt"
            Get-Content .\lastDir.txt >> $outputFile
        }
    }
}

function Get-Command-Line-Arguments
{
    $errorMessage = "CommandLineArguments from MetricsExtension.Native.exe were not found."

    try
    {
        $commandLineArguments = (Get-WmiObject Win32_Process -Filter "Name='MetricsExtension.Native.exe'").CommandLine
        if (-Not [string]::IsNullOrEmpty($commandLineArguments))
        {
            $commandLineArguments > CommandLineArgumentsME.txt
            return $commandLineArguments
        }
    }
    catch
    {
        $errorMessage += " Exception: $_"
        Write-Error $errorMessage
    }

    $errorMessage > CommandLineArgumentsME.txt
    return [string]::Empty
}

function Get-Cached-Config([String]$commandLineArguments)
{
    $dataDirectories = Get-Data-Directories $commandLineArguments
    $counter = 1

    foreach ($dataDirectory in $dataDirectories)
    {
        if (Test-Path -Path $dataDirectory)
        {
            Invoke-Command "New-Item -ItemType Directory -Path .\MetricsExtensionCachedConfig_$counter"
            Invoke-Command "Copy-Item -Path '$dataDirectory*' -Destination '.\MetricsExtensionCachedConfig_$counter' -Recurse -Force"
            $counter++
        }
    }
}

function Get-Data-Directories([String]$commandLineArguments)
{
    # As there could be several ME processes running at the same time, we will collect the data directories of all of them
    $dataDirectories = @()

    # Try to use the -DataDirectory parameter
    if (-Not [string]::IsNullOrEmpty($commandLineArguments))
    {
        $commandLineArgumentsArray = $commandLineArguments.Split(" ")
        for ($i = 1; $i -lt $commandLineArgumentsArray.Count; $i++)
        {
            $arg = $commandLineArgumentsArray[$i]
            if ($arg -eq "-DataDirectory")
            {
                $i++
                $dataDirectory = $commandLineArgumentsArray[$i]
                $dataDirectory = $dataDirectory.Replace('"', '')
                if ($dataDirectory[-1] -ne '\')
                {
                    $dataDirectory += '\'
                }
                $dataDirectories += $dataDirectory
            }
        }
    }

    # Try to get the path from env var MONITORING_DATA_DIR
    if (Test-Path env:MONITORING_DATA_DIR)
    {
        $dataDirectories += $env:MONITORING_DATA_DIR + '\MetricsExtensionData\'
    }

    # Try to get the path from env var DiagnosticStore
    if (Test-Path env:DiagnosticStore)
    {
        $dataDirectories += $env:DiagnosticStore + '\MetricsExtensionData\'
    }

    # Get the path from TEMP dir
    $dataDirectories += $env:TEMP + '\MetricsExtensionData\'

    return $dataDirectories
}

function Copy-Autopilot-Logs
{
    if (Test-Path -Path D:\Data\logs\local)
    {
        Write-Output "Copying autopilot logs..."
        Invoke-Command "mkdir .\GenevaMetricsExtensionLogs"
        Invoke-Command "Copy-Item -Path (Get-ChildItem D:\Data\logs\local\GenevaMetricsExtension_*.log) -Destination GenevaMetricsExtensionLogs"
        Invoke-Command "mkdir .\GenevaMetricsExtensionHostLogs"
        Invoke-Command "Copy-Item -Path (Get-ChildItem D:\Data\logs\local\GenevaMetricsExtensionHost_*.log) -Destination GenevaMetricsExtensionHostLogs"
    }
    else
    {
        Write-Warning "No autopilot logs were found. If this machine is not an Autopilot machine, this is not an issue."
    }
}

function Get-Autopilot-Ini
{
    if (Test-Path -Path D:\app\autopilot.ini)
    {
        Write-Output "Attempting to collect autopilot.ini..."
        Write-Output "Attempting to collect autopilot.ini..." > CollectAutopilotLogs.txt
        Invoke-Command "xcopy /C D:\app\autopilot.ini >> CollectAutopilotLogs.txt"
    }
    else
    {
        Write-Warning "D:\app\autopilot.ini was not found. If this machine is not an Autopilot machine, this is not an issue."
    }
}


function Convert-Tsf-Logs-To-Csv([String]$table2csv)
{
    $tsfCounter = 0
    foreach ($tsfLog in Get-Content -Path .\TsfLogs.txt)
    {
        try
        {
            Write-Output "$table2csv $Table2CsvParameters $tsfLog"
            Write-Output "Waiting for Table2Csv to complete..."
            Write-Output "${table2csv} $Table2CsvParameters} ${tsfLog}" >> Table2CsvLogs.txt
            Invoke-Expression "${Table2Csv} ${Table2CsvParameters} '${tsfLog}'" >> Table2CsvLogs.txt
        }
        catch
        {
            "ERROR: Command {$table2csv $Table2CsvParameters '$tsfLog'} Failed: $_" >> Table2CsvLogs.txt
            Write-Error "ERROR: Command {$table2csv $Table2CsvParameters '$tsfLog'} Failed: $_"
        }

        $tsfCounter++
        $csvFullPath = $tsfLog.Replace("tsf","csv")
        $tsfLogFileName = Split-Path $tsfLog -Leaf
        $csvLogFileName = $tsfLogFileName.Replace(".tsf", "_${tsfCounter}.csv")
        try
        {
            Write-Output "Copy-Item '${csvFullPath}' ${csvLogFileName}"
            Invoke-Command "Copy-Item '${csvFullPath}' .\${csvLogFileName} 2>> CsvCopyErrors.txt"
        }
        catch
        {
            "ERROR: Command {failed to copy ${csvFullPath} to .\${csvLogFileName}}: $_" >> CsvCopyErrors.txt
            Write-Error "ERROR: Command {failed to copy ${csvFullPath} to .\${csvLogFileName}}: $_"
        }
    }
}

function Get-Etw-Session-And-IfxMetrics-At-End
{
    tasklist /M IfxMetrics.dll /FO CSV > ProcessLoadingIfxMetrics_At_End.csv
    logman NativeMetricsExtension_Provider -ets > MetricsExtensionEtwSessionAtEnd.txt
}

function Compress-Output([String]$compressedDataOutput, [String]$mdmDataCollectionOutput)
{
    Write-Output "Compressing MDM Data Collection Output ..."
    try
    {
        Invoke-Command "Compress-Archive -Force -Path .\* -DestinationPath '$OutputDirectory\$compressedDataOutput'"
        Invoke-Command "Set-Location .."
        Invoke-Command "Remove-Item -r -Force $mdmDataCollectionOutput"
        Write-Output "Done -^> MDM Data ready at $OutputDirectory\$compressedDataOutput"
    }
    catch
    {
        Write-Error "ERROR: MDM Data Collection Output has not been compressed: $_"
    }
}

function Show-Ending-Message
{
    $date = Get-Date
    Write-Output "End - MDM Data Collection Script - $date"
}

function Invoke-Command([String]$command)
{
    $output = Invoke-Expression $command
    if ($DebugMdmDataCollection)
    {
        Write-Output $output
    }
}

function Test-Connection-To-URL([String]$cppRestUtil, [String]$url)
{
    try
    {
        if ([String]::IsNullOrEmpty($cppRestUtil))
        {
            [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
            Write-Output "(New-Object System.IO.StreamReader ((([System.Net.WebRequest]::Create($url)).GetResponse()).GetResponseStream())).ReadToEnd()"
            (New-Object System.IO.StreamReader ((([System.Net.WebRequest]::Create($url)).GetResponse()).GetResponseStream())).ReadToEnd()
        }
        else
        {
            Write-Output "'$cppRestUtil' --json $url"
            Invoke-Expression "& '$cppRestUtil' --json $url"
        }
    }
    catch
    {
        "Request to $url failed."
    }

    Write-Output ""
}

function Search-Table2csv([String]$monAgentHostPath)
{
    if ((-Not [string]::IsNullOrEmpty($Table2CsvPathParam)) -and (Test-Path -Path $Table2CsvPathParam))
    {
        return $Table2CsvPathParam
    }

    if (-Not [string]::IsNullOrEmpty($monAgentHostPath) -And $monAgentHostPath.Contains("MonAgentHost.exe"))
    {
        $table2CsvPath = $monAgentHostPath.Replace("MonAgentHost.exe","table2csv.exe")
        if (Test-Path -Path $table2CsvPath)
        {
            return $table2CsvPath
        }
    }

    return [string]::Empty
}

function Get-Tsf-Logs([Object[]]$logicalDisks, [String]$mdmDataCollectionOutput, [String]$monAgentHostPath)
{
    if ($SkipCollectionTsfLogs)
    {
        Write-Warning "SkipCollectionTsfLogs has been set, skipping the collection of tsf logs."
    }
    else
    {
        $fileNames = @(
            "MaMetricsExtensionEtw.tsf"
            "MAEventTable.tsf"
            "LocallyAggregatedMdmMetricsV1.tsf"
        )

        $table2csv = Search-Table2csv $monAgentHostPath
        if ([string]::IsNullOrEmpty($table2csv))
        {
            $warningMessage = "table2csv.exe was not found. Tsf logs will not be collected."
            $warningMessage += "Please take in account this scenario is useful only if you are using MonitoringAgent"
            Write-Warning $warningMessage
        }
        else
        {
            Search-Files-Job $fileNames $logicalDisks "TsfLogs.txt" "$PSScriptRoot\$mdmDataCollectionOutput"
            Convert-Tsf-Logs-To-Csv $table2csv
        }
    }
}

if (-Not $ImportFunctions)
{
    Main
}

# SIG # Begin signature block
# MIIoKQYJKoZIhvcNAQcCoIIoGjCCKBYCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCA+SYwK6aSxmkQa
# MrnYTFJMM31grDuHpogCjLtajE58raCCDXYwggX0MIID3KADAgECAhMzAAADrzBA
# DkyjTQVBAAAAAAOvMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoa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