Uninstalling Old 7-Zip Versions with PowerShell and InTune



In today's digitally driven landscape, cybersecurity remains a top priority for organizations worldwide. As technology evolves, so do potential vulnerabilities that could expose systems to security risks. One such vulnerability often lies in outdated software versions, which can serve as an entry point for cyber threats. To address this, organizations often resort to proactive measures, such as employing remediation scripts to identify and eliminate outdated software.

One such remediation script, designed in PowerShell, focuses on detecting and removing old versions of 7Zip from devices within an organization. While the script's technical details are intricate, its overarching goal is to reduce potential vulnerabilities by eradicating outdated 7Zip installations.

The script operates in two distinct phases: detection and remediation.


7-Zip Detection Script:

The detection script conducts a thorough scan across devices to identify older versions of 7Zip. It uses specific parameters to search for installations attributed to the vendor "Igor Pavlov" the author of 7-zip, and examines the versions present. If it detects any instances of 7Zip with versions older than "23.01.00.0," it logs a message indicating the discovery of the outdated version and will trigger the remediation script to run.

Note: you can change the version number directly in the code, the minimum version in the code below was at the time of writing and software versions change frequently.

#Script detects Old versions of 7-Zip on Windows and Uninstalls.

$7Zip = Get-WmiObject -Class Win32_Product | where vendor -eq "Igor Pavlov"

$FoundOld7Z = $false

#For each object if version is lt or equal to 23.01.00.0

$7Zip | ForEach-Object {
if([version]::Parse($_.Version) -lt [version]::Parse("23.01.00.0")){
Write-Host "Detected Old Zoom Version "$_.Version
$FoundOld7Z = $true
}
}


if($FoundOld7Z){
  Write-Host "Old 7Zip Found"
  Exit 1
}
else{
Write-Host "Old 7Zip not found"
exit 0
}

7-Zip Remediation Script:

Upon identifying outdated 7Zip installations, the remediation script takes swift action. It reiterates the process of scanning through 7Zip installations and, upon detecting older versions, initiates an uninstallation process for those versions. This proactive approach ensures that the organization's devices are running the latest and more secure versions of 7Zip, thereby reducing potential vulnerabilities that could be exploited by cyber threats.

$7Zip = Get-WmiObject -Class Win32_Product | where vendor -eq "Igor Pavlov"

$7Zip | ForEach-Object {
if([version]::Parse($_.Version) -lt [version]::Parse("23.01.00.0")){
Write-Host "Detected Old 7-Zip Version "$_.Version
$_.UnInstall()
}
}

Significance and Benefits:

Implementing such remediation scripts plays a pivotal role in enhancing an organization's cybersecurity posture. By proactively identifying and removing outdated software versions like 7Zip, the organization significantly reduces the attack surface for potential threats. It also aligns with best practices of maintaining a secure and up-to-date software environment.

Conclusion:

In an era where cyber threats are increasingly sophisticated, preventative measures are crucial. PowerShell remediation scripts like the one designed for detecting and removing old 7Zip versions represent a proactive and effective approach to mitigating vulnerabilities. Regularly employing such scripts aids in bolstering an organization's cybersecurity defenses, ensuring a more secure and resilient technological infrastructure.

By prioritizing the use of scripts like these and staying vigilant against potential vulnerabilities, organizations can effectively minimize risks, safeguard sensitive information, and fortify their cybersecurity posture in an ever-evolving digital landscape.

It's worth noting that scripts like the above do not replace other security systems but depending on what tools you have in your environment scripts like this can fill a need or compliment existing tools.

I intend to make more articles like this based on remediation scripts that you can deploy through InTune.


Was this helpful?

Yes No


Comments