Poweshell Script information not update after install

Salachour Ebaratgar 1 Reputation point
2022-02-07T23:51:17.233+00:00

Hello,

I create a script that looking for the Bluetooth driver model and install the new driver for this model.

Before the install i get the driver version and put it in a registry key before update, if it’s not the last version my script do the install at the end of the install i get the driver version to put it in a second registry key, here come the problem if i look on the post the information a the right version but my script get the old version bu if i rerun the script he get the update information.

I try de restart winmngt service but that doesn’t change
In the registry is the same new information are not available.

How can i fix it ? Without running the script a second time.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,405 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Salachour Ebaratgar 1 Reputation point
    2022-02-08T08:52:11.743+00:00
    <#
    #Intel Bluetooth 22.90
    
    
    #Script Version 1.1
    
    
    #Relase 1
    
    
    
    #Variable Logiciel
    
    $DisplayName = "*Wireless Bluetooth*"
    $Install_Intel = ".\Intel_BT_22_90.exe"
    
    #Variable Msi
    
    $Arguments = @(   "/quiet",
                      "/norestart"
                  )
    
    #Variable RegEdit
    #
    $Regpath = @(
                "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
                "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
                )
    $RegBt = @(
                "HKLM:\SOFTWARE\Bt\"
                "HKLM:\SOFTWARE\WOW6432Node\Bt\"
                )
    $SoftName = Get-ItemProperty $RegPath | where{$_.DisplayName -like "$DisplayName"} | Select DisplayName
    $SoftVersion = Get-ItemProperty $RegPath | where{$_.DisplayName -like "$DisplayName"} | Select DisplayVersion
    $SoftInstalldate = Get-ItemProperty $RegPath | where{$_.DisplayName -like "$DisplayName"} | Select InstallDate
    $SoftBtInstalled = @(
                           "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{00002090-0220-1036-84C8-B8D95FA3C8C3}"
                           "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{00002090-0220-1036-84C8-B8D95FA3C8C3}"
                        ) 
    
    $HKLM_Script_Version = @(
                            "HKLM:\SOFTWARE\BT\"
                            "HKLM:\SOFTWARE\WOW6432Node\BT\"
                            )
    
    $ScriptVersion = Get-ItemProperty -Path $HKLM_Script_Version -Name "Bluetooth_ScriptVersion" -ErrorAction SilentlyContinue
    
    #Variable System 
    
    $DayExecution = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    
    #Variable Plug and Play 
    $All_PnpBt_DriverVersion = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "*Wireless Bluetooth*"}| Select DriverVersion
    $All_PnpBt_Description = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "*Wireless Bluetooth*"}| Select Description
    $All_Bt_DriverVersion = ($All_PnpBt_DriverVersion).DriverVersion
    $All_Bt_Description =  ($All_PnpBt_Description).Description
    
    #Intel
    $Intel_PnpBt_DriverVersion = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "Intel*Wireless Bluetooth*"}| Select DriverVersion
    $Intel_PnpBt_Description = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "Intel*Wireless Bluetooth*"}| Select Description
    $Intel_PnpBt_AdapterModel = Get-WmiObject Win32_PnPSignedDriver | where{$_.DeviceClass -eq "NET" -and $_.Description -notlike "*Virtual*" -and ($_.Description -like "Intel*Wireless*" -or $_.Description -like "Intel*Wi-fi*")}
    $Intel_Bt_DriverVersion = ($Intel_PnpBt_DriverVersion).DriverVersion
    $Intel_Bt_Description =  ($Intel_PnpBt_Description).Description
    $Intel_AdapterModel_Description = ($Intel_PnpBt_AdapterModel).Description
    
    #Killer
    $Killer_PnpBt_DriverVersion = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "*Killer*Wireless Bluetooth*"}| Select DriverVersion
    $Killer_PnpBt_Description = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "*Killer*Wireless Bluetooth*"}| Select Description
    $Killer_PnpBt_AdapterModel = Get-WmiObject Win32_PnPSignedDriver | where{$_.DeviceClass -eq "NET" -and $_.Description -notlike "*Virtual*" -and ($_.Description -like "*Killer*Wireless*" -or $_.Description -like "*Killer*Wi-fi*")}
    $Killer_Bt_DriverVersion = ($Killer_PnpBt_DriverVersion).DriverVersion
    $Killer_Bt_Description =  ($Killer_PnpBt_Description).Description
    $Killer_AdapterModel_Description = ($Killer_PnpBt_AdapterModel).Description
    
    #Other
    $Other_PnpBt_DriverVersion = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "*Wireless Bluetooth*" -and ($_.Description -notlike "Intel*Wireless Bluetooth*" -or $_.Description -notlike "Killer*Wireless Bluetooth*")}| Select DriverVersion
    $Other_PnpBt_Description = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "Killer*Wireless Bluetooth*" -and ($_.Description -notlike "Intel*Wireless Bluetooth*" -or $_.Description -notlike "Killer*Wireless Bluetooth*")}| Select Description
    $Other_PnpBt_AdapterModel = Get-WmiObject Win32_PnPSignedDriver | where{$_.DeviceClass -eq "NET" -and $_.Description -notlike "*Virtual*" -and ($_.Description -like "*Wireless*" -or $_.Description -like "*Wi-fi*") -and ($_.Description -notlike "Intel*" -or $_.Description -notlike "Killer*")}
    $Other_Bt_DriverVersion = ($Other_PnpBt_DriverVersion).DriverVersion
    $Other_Bt_Description =  ($Other_PnpBt_Description).Description
    $Other_AdapterModel_Description = ($Other_PnpBt_AdapterModel).Description
    
    #Switch
    if($Intel_Bt_Description -ne $null)
    {
        Switch -Wildcard ($Intel_AdapterModel_Description)
        {
        "Intel*AX211*"{$Version = "22.90.2.1"}
        "Intel*AX201*"{$Version = "22.90.2.1"}
        "Intel*AX210*"{$Version = "22.90.0.4"}
        "Intel*AC 9560*"{$Version = "22.90.0.4"}
        "Intel*AC 9462*"{$Version = "22.90.0.4"}
        "Intel*AC 9461*"{$Version = "22.90.0.4"}
        "Intel*AC 9460*"{$Version = "22.90.0.4"}
        "Intel*AC 8265*"{$Version = "22.90.0.4"}
        "Intel*AC 8260*"{$Version = "22.90.0.4"}
        "Intel*AC 3168*"{$Version = "20.100.10.5"}
        "Intel*AC 3165*"{$Version = "20.100.10.5"}
        "Intel*7265 Familly*"{$Version = "20.100.10.5"}
        default {$Version = "IntelNA"}
        }
    
        Write-Host "Version Intel : " $Version
    }
    
    if($Killer_Bt_Description -ne $null)
    {
        Switch -Wildcard ($Killer_AdapterModel_Description)
        {
        "*AC 1550*"{$VersionKiller = "22.100.1.1"}
        "*AX1650*"{$VersionKiller = "22.100.1.1"}
        "*AX1675*"{$VersionKiller = "22.100.1.1"}
        default {$VersionKiller = "KillerNA"}
        }
    
        Write-Host "Version Killer : " $Versionkiller
    
    }
    
    
    if($Other_Bt_Description -ne $null)
    {
    
     Set-Variable -Name VersionOther -Value "Other"
    
     Write-Host "Model : " $VersionOther
    
    }
    
    
    
    #Intel Bluetooth 22.90
    
    #Pre-install
    
    if ($ScriptVersion -eq $null)
    {
    Write-Host "Version actuelement sur le poste avant la mise à jour"
    
    New-ItemProperty  -Path $RegBt -Name "Bluetooth_Before_Update_Version" -Value $All_Bt_DriverVersion -Force
    
    New-ItemProperty  -Path $RegBt -Name "Bluetooth_Before_Update_Description" -Value $All_Bt_Description -Force
    }
    
    #
    #Installation du Intel Bluetooth 22.90
    #
    
    if ($Intel_Bt_DriverVersion -ne "22.100.1.1")
        {
    
            if($Intel_Bt_DriverVersion -ne $Version)
            {
    
                            Write-Host "Installation du Bluetooth"
    
                            Start-Process -FilePath $Install_Intel  -ArgumentList $Arguments -Wait -WindowStyle Hidden
             }                                       
        }
    Else
        {
        Set-Variable -Name RunIvantaire -Value "YES"
        }
    
    
    
    #Intel Bluetooth 22.90
    
    #Post-install
    
    Stop-Service -Force  -Name Winmgmt -Verbose
    
    Start-Service -Name Winmgmt -Verbose
    
    $All_PnpBt_DriverVersion_AFI = Get-WmiObject Win32_PnPSignedDriver | where{$_.Description -like "*Wireless Bluetooth*"}| Select DriverVersion
    $All_Bt_DriverVersion_AFI = ($All_PnpBt_DriverVersion_AFI).DriverVersion
    
    New-ItemProperty  -Path $RegBt -Name "Bluetooth_Value_Found" -Value $All_Bt_DriverVersion_AFI -Force
    
    New-ItemProperty  -Path $RegBt -Name "Bluetooth_Install" -Value ($SoftInstalldate).InstallDate -Force
    
    New-ItemProperty  -Path $RegBt -Name "Bluetooth_ScriptVersion" -Value "Version 1.1" -Force
    
    New-ItemProperty  -Path $RegBt -Name "Bluetooth_ScriptDate" -Value $DayExecution -Force
    
    if($Intel_AdapterModel_Description -ne $null -and $Version -ne "IntelNA")
    {
        if ($Intel_Bt_DriverVersion -eq $Version) 
            {   
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Value_Reference" -Value $Version -Force
    
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Status" -Value "OK" -Force
            }
        Elseif ($Intel_Bt_DriverVersion -match "22.100")
            {
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Value_Reference" -Value $Version -Force
    
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Status" -Value "NEWER" -Force
            }
        Elseif ($Intel_Bt_DriverVersion -ne $Version)
            {
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Status" -Value "NOK" -Force
            }
    }
    
    if($Killer_AdapterModel_Description -ne $null -and $Versionkiller -ne "KillerNA")
    {
        if ($Killer_Bt_DriverVersion -eq $Versionkiller) 
            {   
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Value_Reference" -Value $Versionkiller -Force
    
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Status" -Value "OK" -Force
            }
        Elseif ($Killer_Bt_DriverVersion -match "22.100")
            {
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Value_Reference" -Value $Versionkiller -Force
    
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Status" -Value "NEWER" -Force
            }
        Elseif ($Killer_Bt_DriverVersion -ne $Versionkiller)
            {
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Value_Reference" -Value $Versionkiller -Force
    
                New-ItemProperty  -Path $RegBt -Name "Bluetooth_Status" -Value "NOK" -Force
            }
    }
    
    if($Versionother -eq "Other")
    {
     New-ItemProperty  -Path $RegBt -Name "Bluetooth_Value_Reference" -Value "UNKNOWN" -Force
    
     New-ItemProperty  -Path $RegBt -Name "Bluetooth_Status" -Value "NA" -Force
    
    }