lue
function RunDiagnosticScript([string]$scriptPath)
{
    if([string]::IsNullorEmpty($scriptPath) -or -not (Test-Path $scriptPath))
    {
        WriteFunctionExceptionReport "RunDiagnosticScript" $localizationString.throw_invalidFileName
        return
    }
    $result = &($scriptPath)
    if($result -is [bool])
    {
        return [bool]$result
    }
    else
    {
        return $false
    }
}

# Convert string to the PSObject and set the string as property value to specified property name
function ConvertStringToPSObject([string]$propertyName, [string]$propertyValue)
{
    $obj = New-Object -TypeName System.Management.Automation.PSObject
    Add-Member -InputObject $obj -MemberType NoteProperty -Name $propertyName -Value $propertyValue
    return $obj
}

# Convert string array to the PSObject array and set the string value as property value to specified property name
function ConvertStringArrayToPSObjectArray($stringArray, [string]$propertyName)
{
    if($stringArray -eq $null)
    {
        return $null
    }
    $objArray = New-Object System.Collections.ArrayList
    foreach( $str in $stringArray)
    {
        $objArray += ConvertStringToPSObject $propertyName $str
    }
    return $objArray
}

# Write function exception to debug report
function WriteFunctionExceptionReport([string]$functionName, [string]$exceptionInfo)
{
    [string]$errorFunctionName = [System.String]::Format([System.Globalization.CultureInfo]::InvariantCulture, $localizationString.error_function_name, $functionName)
    [string]$errorFunctionDescription = [System.String]::Format([System.Globalization.CultureInfo]::InvariantCulture, $localizationString.error_function_description, $functionName)
    $obj = ConvertStringToPSObject "exceptionInformation" $exceptionInfo
    $obj | select-object -Property @{Name=$localizationString.error_information; Expression={$_.exceptionInformation}} | convertto-xml | Update-DiagReport -id $functionName -name $errorFunctionName -description $errorFunctio# Copyright  2008, Microsoft Corporation. All rights reserved.

# Look for forced shutdown events that do not involve corruption (since those do not automatically force Restore Defaults)

# Load utility library
. .\CL_Utility.ps1

Write-DiagProgress -activity $localizationString.progress_ts_indexingServiceForcedShutdown

$event = get-winevent -LogName application -FilterXPath "*[System[Provider[@Name='Search'] and (EventID=7042)]]" -ErrorAction SilentlyContinue | where { $_.Message -notlike "*corrupt*" }
if ($event -ne $null -and $event.Count -gt 0)
{
    Update-DiagRootCause -id "RC_ForcedShutdownNoCorruption" -Detected $true
    $event | convertto-xml | Update-DiagReport -id IndexerEvent -name $localizationString.indexerEvent_name -description $localizationString.indexerEvent_description -verbosity Error -rid "RC_ForcedShutdownNoCorruption"
} else {
    Update-DiagRootCause -id "RC_ForcedShutdownNoCorruption" -Detected $false
}
