Pages

Sunday, 28 June 2020

Installed application version through PS script

$InstalledGCVer = (Get-WmiObject -Class CIM_DataFile -Filter "Name='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'" | Select-Object Version).Version

#If ($PackagedGCVer -ge $InstalledGCVer)
if ($InstalledGCVer)
{
If ([System.Version]$InstalledGCVer -gt  [System.Version]$appVersion)
{
 Show-InstallationPrompt -Message 'Newer version Google Chrome x64 '$appVersion' is already installed.' -ButtonRightText 'OK' -Icon Information -NoWait
 Write-Log -Message "Newer version Google Chrome x64 '$appVersion' is already installed."
 New-Item -Path $regpath -type Directory -Force | New-ItemProperty -Name $name -Value $value -PropertyType string -Force | Out-Null
 
}
elseif ([System.Version]$InstalledGCVer -eq  [System.Version]$appVersion)
{
 Show-InstallationPrompt -Message 'Google Chrome x64 '$appVersion' is already installed.' -ButtonRightText 'OK' -Icon Information -NoWait
 Write-Log -Message "Google Chrome x64 '$appVersion' is already installed."
 New-Item -Path $regpath -type Directory -Force | New-ItemProperty -Name $name -Value $value -PropertyType string -Force | Out-Null
}
elseif ([System.Version]$InstalledGCVer -lt  [System.Version]$appVersion)
{
    # Show Welcome Message, close Chrome if required
    Show-InstallationWelcome -CloseApps "Chrome" -silent
    # Show Progress Message (with the default message)
    Show-InstallationProgress
    Remove-MSIApplications "Google Chrome"
    Remove-MSIApplications "Google Update Helper"
}

No comments:

Post a Comment

User based detection

function getloggedindetails () {     ##Find logged in username     $user = Get-WmiObject Win32_Process - Filter "Name='explorer...

Search This Blog