Skip to main content
edited title
Link
S. Me
  • 23
  • 3

Are those remediation Intune Remediation script well constructed according to you?uninstall 7-Zip

deleted 55 characters in body
Source Link
toolic
  • 16.4k
  • 6
  • 29
  • 221

JustI just wanted to have some advicesadvice on those remediation script,scripts; what do you think  ?

if you got some time to give me some advice, thank you

Detection Script  :

$64bits = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if ($64bits){
    foreach ($soft in $64bits){

        if ($soft.DisplayVersion -lt "23.01"){
            
            Write-host "Uninstall" $soft.DisplayName $soft.DisplayVersion
            Start-Process $soft.UninstallString -ArgumentList "/S"
        }
    }
}
$32bits = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if ($32bits){

    foreach ($soft in $32bits){

        if ($soft.DisplayVersion -lt "23.01" -or $soft.DisplayVersion -eq $null){
            Write-Host "7-Zip(x86) ver:" $soft.DisplayVersion "detected"

            Start-Process $soft.UninstallString -ArgumentList "/S"
            Write-host "Uninstall" $soft.DisplayName $soft.DisplayVersion
        }
    }
}
exit 0
````

Just wanted to have some advices on those remediation script, what do you think  ?

if you got some time to give me some advice, thank you

Detection Script  :

$64bits = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if ($64bits){
    foreach ($soft in $64bits){

        if ($soft.DisplayVersion -lt "23.01"){
            
            Write-host "Uninstall" $soft.DisplayName $soft.DisplayVersion
            Start-Process $soft.UninstallString -ArgumentList "/S"
        }
    }
}
$32bits = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if ($32bits){

    foreach ($soft in $32bits){

        if ($soft.DisplayVersion -lt "23.01" -or $soft.DisplayVersion -eq $null){
            Write-Host "7-Zip(x86) ver:" $soft.DisplayVersion "detected"

            Start-Process $soft.UninstallString -ArgumentList "/S"
            Write-host "Uninstall" $soft.DisplayName $soft.DisplayVersion
        }
    }
}
exit 0
````

I just wanted to have some advice on those remediation scripts; what do you think?

Detection Script:

$64bits = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if ($64bits){
    foreach ($soft in $64bits){

        if ($soft.DisplayVersion -lt "23.01"){
            
            Write-host "Uninstall" $soft.DisplayName $soft.DisplayVersion
            Start-Process $soft.UninstallString -ArgumentList "/S"
        }
    }
}
$32bits = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if ($32bits){

    foreach ($soft in $32bits){

        if ($soft.DisplayVersion -lt "23.01" -or $soft.DisplayVersion -eq $null){
            Write-Host "7-Zip(x86) ver:" $soft.DisplayVersion "detected"

            Start-Process $soft.UninstallString -ArgumentList "/S"
            Write-host "Uninstall" $soft.DisplayName $soft.DisplayVersion
        }
    }
}
exit 0
Source Link
S. Me
  • 23
  • 3

Are those remediation script well constructed according to you?

Just wanted to have some advices on those remediation script, what do you think ?

The idea is to detect every 7-Zip installed on the computer and search for those not up to date and uninstall them. Got some Struggle with placing correctly the exits code used by Intune.

if you got some time to give me some advice, thank you

Detection Script :

$64bits = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"
$32bits = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if (!($64bits) -and !($32bits)){
    Write-Host "7-Zip isnt detected at all"
    exit 0
}

if ($64bits){
    foreach ($soft in $64bits){
        Write-Host "7-Zip(x64) ver:" $soft.DisplayVersion "detected"
        if ($soft.DisplayVersion -lt "23.01"){
            exit 1
        }
    }
}
else {
    Write-Host "7-Zip(x64) isnt detected"
}

if ($32bits){
    foreach ($soft in $32bits){
        Write-Host "7-Zip(x86) ver:" $soft.DisplayVersion "detected"
        if ($soft.DisplayVersion -lt "23.01"){
            exit 1
        }
    }
}
else {
    Write-Host "7-Zip(x86) isnt detected"
}

Remediation Script :

$64bits = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if ($64bits){
    foreach ($soft in $64bits){

        if ($soft.DisplayVersion -lt "23.01"){
            
            Write-host "Uninstall" $soft.DisplayName $soft.DisplayVersion
            Start-Process $soft.UninstallString -ArgumentList "/S"
        }
    }
}
$32bits = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "7-Zip"

if ($32bits){

    foreach ($soft in $32bits){

        if ($soft.DisplayVersion -lt "23.01" -or $soft.DisplayVersion -eq $null){
            Write-Host "7-Zip(x86) ver:" $soft.DisplayVersion "detected"

            Start-Process $soft.UninstallString -ArgumentList "/S"
            Write-host "Uninstall" $soft.DisplayName $soft.DisplayVersion
        }
    }
}
exit 0
````