e);
            }
            else
            {
                res = PowerConfig.PowerReadDCValueIndex(0, ref activeSchemeGuid, ref subGroupGuid,
                      ref settingGuid,
                      ref value);
            }

            return res;
        }

        public static uint WritePowerSetting(bool ac,
                                     ref Guid activeSchemeGuid,
                                     ref Guid subGroupGuid,
                                     ref Guid settingGuid,
                                     UInt32 newValue)
        {
            uint res = 0;
            if (ac)
            {
                res = PowerConfig.PowerWriteACValueIndex(0, ref activeSchemeGuid, ref subGroupGuid,
                                     ref settingGuid,
                                     newValue);
            }
            else
            {
                res = PowerConfig.PowerWriteDCValueIndex(0, ref activeSchemeGuid, ref subGroupGuid,
                                     ref settingGuid,
                                     newValue);
            }
            if (res == 0)
            {
                res = PowerConfig.PowerSetActiveScheme(0,
                                       ref activeSchemeGuid);
            }
            return res;
        }

        public static Guid BalancedPowerPlan()
        {
            Guid subgroup = new Guid("fea3413e-7e05-4911-9a71-700331f1c294");
            Guid setting = new Guid("245d8541-3943-4422-b025-13a784f679b7");

            Guid Buffer = new Guid();
            Guid BalancedGuid = new Guid();
            UInt32 SchemeIndex = 0;
            UInt32 BufferSize = (UInt32)Marshal.SizeOf(typeof(Guid));

            while (0 == PowerConfig.PowerEnumerate(0, IntPtr.Zero, IntPtr.Zero, 16, SchemeIndex, ref Buffer, ref BufferSize))
            {
                uint ACvalue = 0;
                uint DCvalue = 0;

                PowerConfig.ReadPowerSetting(true, ref Buffer, ref subgroup, ref setting, ref ACvalue);
                PowerConfig.ReadPowerSetting(false, ref Buffer, ref subgroup, ref setting, ref DCvalue);

                if ((2 == ACvalue) && (2 == DCvalue))
                {
                    BalancedGuid = Buffer;
                }
                SchemeIndex++;
            }
            return BalancedGuid;
        }

        public static UInt32 CheckPowerSetting(bool ac,Guid guid)
        {
            UInt32 result;
            if (ac)
            {
                result = PowerConfig.PowerSettingAccessCheck(POWER_DATA_ACCESSOR.ACCESS_AC_POWER_SETTING_INDEX, guid);
            }
            else
            {
                result = PowerConfig.PowerSettingAccessCheck(POWER_DATA_ACCESSOR.ACCESS_DC_POWER_SETTING_INDEX, guid);
            }
            return result;
        }

        public static UInt32 CheckActiveSchemeAccess()
        {
            UInt32 result;
            result = PowerConfig.PowerSettingAccessCheck(POWER_DATA_ACCESSOR.A# Copyright  2008, Microsoft Corporation. All rights reserved.

Import-LocalizedData -BindingVariable localizationString -FileName CL_LocalizationData

Write-DiagProgress -activity $localizationString.progress_ts_multipleAntivirusProducts

$antivirusProducts = Get-WmiObject -Query "Select * From AntiVirusProduct Where OnAccessScanningEnabled='true'" -Namespace "root/SecurityCenter"

if($antivirusProducts.Count -gt 1)
{
    Update-DiagRootCause -id "RC_MultipleAntivirusProducts" -Detected $true
} else {
    Update-DiagRootCause -id "RC_MultipleAntivirusProducts" -Detected $false
}

if($antivirusProducts -ne $null)
{
    $propertyArray = New-Object System.Collections.ArrayList
    $propertyArray += @{Name=$localizationString.antivirusProducts_companyName; Expression={$_.companyName}}
    $propertyArray += @{Name=$localizationString.antivirusProducts_displayName; Expression={$_.displayName}}
    $propertyArray += @{Name=$localizationString.antivirusProducts_onAccessScanningEnabled; Expression={$_.onAccessScanningEnabled}}
    $propertyArray += @{Name=$localizationString.antivirusProducts_pathToSignedProductExe; Expression={$_.pathToSignedProductExe}}
    $propertyArray += @{Name=$localizationString.antivirusProducts_versionNumber; Expression={$_.versionNumber}}
    $antivirusProducts | select-object -Property $propertyArray | convertto-xml | Update-DiagReport -id AntivirusProducts -name $localizationString.antivirusProducts_name -verbosity Informational -rid "RC_MultipleAntivirusProducts"
}