setupapi.dll", SetLastError = true, EntryPoint = "SetupDiOpenDeviceInfo", CharSet = CharSet.Auto)]
        static extern UInt32 SetupDiOpenDeviceInfo(IntPtr DeviceInfoSet, [MarshalAs(UnmanagedType.LPWStr)]string DeviceID, IntPtr Parent, UInt32 Flags, ref SP_DEVINFO_DATA DeviceInfoData);

        [DllImport("setupapi.dll", SetLastError = true, EntryPoint = "SetupDiCreateDeviceInfoList", CharSet = CharSet.Unicode)]
        static extern IntPtr SetupDiCreateDeviceInfoList(IntPtr ClassGuid, IntPtr Parent);

        [DllImport("setupapi.dll", SetLastError = true, EntryPoint = "SetupDiDestroyDeviceInfoList", CharSet = CharSet.Auto)]
        static extern UInt32 SetupDiDestroyDeviceInfoList(IntPtr DevInfo);

        [StructLayout(LayoutKind.Sequential)]
        public struct SP_DEVINFO_DATA
        {
            public UInt32 Size;
            public Guid ClassGuid;
            public UInt32 DevInst;
            public IntPtr Reserved;
        }

        private DeviceManagement_Update()
        {
        }

        public static UInt32 GetDeviceInformation(string DeviceID, ref IntPtr DevInfoSet, ref SP_DEVINFO_DATA DevInfo)
        {
            DevInfoSet = SetupDiCreateDeviceInfoList(IntPtr.Zero, IntPtr.Zero);
            if (DevInfoSet == IntPtr.Zero)
            {
                return (UInt32)Marshal.GetLastWin32Error();
            }

            DevInfo.Size = (UInt32)Marshal.SizeOf(DevInfo);

            if(0 == SetupDiOpenDeviceInfo(DevInfoSet, DeviceID, IntPtr.Zero, 0, ref DevInfo))
            {
                SetupDiDestroyDeviceInfoList(DevInfoSet);
                return ERROR_CLASS_MISMATCH;
            }
            return 0;
        }

        public static void ReleaseDeviceInfoSet(IntPtr DevInfoSet)
        {
            SetupDiDestroyDeviceInfoList(DevInfoSet);
        }

        public static UInt32 ShowUpdateWizardForDevice(string DeviceID, string ParentWindowName)
        {
            UInt32 ResultCode = 0;
            UInt32 NeedReboot = 0;
            IntPtr DevInfoSet = IntPtr.Zero;
            SP_DEVINFO_DATA DevInfo = new SP_DEVINFO_DATA();

            ResultCode = GetDeviceInformation(DeviceID, ref DevInfoSet, ref DevInfo);

            if (0 == ResultCode)
            {
                IntPtr ParentHandle = IntPtr.Zero;
                ParentHandle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ParentWindowName);
                if (IntPtr.Zero == ParentHandle)
                {
                    ResultCode = (UInt32)Marshal.GetLastWin32Error();
                }
                else
                {
                    if (DiShowUpdateDevice(ParentHandle, DevInfoSet, ref DevInfo, 0, ref NeedReboot) != 1)
                    {
                        ResultCode = (UInt32)Marshal.GetLastWin32Error();
                    }
                }
                ReleaseDeviceInfoSet(DevInfoSet);
            }

            return ResultCode;
        }
    }
}
"@

    Add-Type -TypeDefinition $ShowUpdateDriverWiz# Copyright  2008, Microsoft Corporation. All rights reserved.


#
#RS_DriverNotFound.ps1
#

PARAM($DeviceName, $DeviceID)

Import-LocalizedData -BindingVariable localizationString -FileName CL_LocalizationData

. .\CL_Utility.ps1

Write-DiagProgress -activity $localizationString.Resolution_DriverNotFound

#
#Get HardwareID for current problematic device
#
$ProblemDevice = Get-WmiObject -Class Win32_PnPEntity | Where-Object -FilterScript {$_.DeviceID -eq $DeviceID}
if(($ProblemDevice -eq $Null) -or ($ProblemDevice.HardwareID.Count -eq $Null) -or ($ProblemDevice.HardwareID.Count -eq 0))
{
    return
}
$ProblemHardwareID = $ProblemDevice.HardwareID

$TargetEvent = $Null
$DriverNotFoundEvents = GetEvent "application" "Windows Error Reporting" 1001
foreach($Event in $DriverNotFoundEvents)
{
    [string]$DeviceIDFromEvent = $Event.Properties[6].Value
    if([String]::IsNullOrEmpty($DeviceIDFromEvent) -eq $False)
    {
        foreach($ID in $ProblemHardwareID)
        {
            if([String]::Compare($DeviceIDFromEvent, $ID, $True) -eq 0)
            {
                $TargetEvent = $Event
                break
            }
        }
        if($TargetEvent -ne $Null)
        {
            break
        }
    }
}

if($TargetEvent -ne $Null)
{
    [string]$Platform = $TargetEvent.Properties[5].Value
    [string]$DeviceID = $TargetEvent.Properties[6].Value

    $QueryResult = QueryWERResponse $Platform $DeviceID

    if($QueryResult -ne $NULL)
    {
        if([String]::IsNullOrEmpty($QueryResult.responseUrl) -eq $True)
        {
            return
        }

        if([String]::IsNullOrEmpty($QueryResult.reportStoreLocation) -eq $True)
        {
            return
        }

        if($QueryResult.isResponseApplicable -eq $False)
        {
            return
        }

        Get-DiagInput -id IT_OpenPRSSolution -param @{'DeviceName'=$DeviceName; 'ReportLocation'=$QueryResult.reportStoreLocation; 'ReportType'=$QueryResult.reportStoreType}
  