<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1678611822423757&amp;ev=PageView&amp;noscript=1">

Deploying MalwareBytes Anti-Malware Utility with PowerShell

Adam Bertram| May 23 2017

| IT insights


malwarebytes-4.jpgHere is how you can deploy MalwareBytes, a popular anti-malware tool, quickly and inexpensively on multiple machines at once with PowerShell. 

All software deployments essentially have three different components; delivery, local execution, and reporting. Delivery is sending the installer(s) to remote systems; local execution means running the installer or script on these systems, and reporting is somehow logging the behavior of the install. Software deployments are similar, but no two are the same due to each piece of software's unique way of needing to be installed. The popular anti-malware utility MalwareBytes is no different.

The first task is downloading the installer. Once you've downloaded the installer, the next step is figuring out a way to get it delivered to each system you'd like to install it on. There are numerous ways to do this and various tools like Microsoft's System Center Configuration Manager (SCCM) or Dell KACE. But these system management services can be costly. For our purposes we're going to do this inexpensively with PowerShell.

I'll start building a script called Install-MalwareBytes.ps1 to get this software deployed. I'll first create an array of computer names I'd like to install MalwareBytes on. I'll then create a foreach loop and copy the installer folder to each of the computers.

$computers = 'PC1','PC2','PC3'
foreach ($computer in $computers) {
    Copy-Item -Path C:\MalwareBytesInstaller -Destination "\\$computer\c$"

Each computer should now have a C:\MalwareBytesInstaller folder with the installer inside. Next, we'll use PowerShell remoting to remotely invoke the installer on each computer. I'm assuming here that you have permission to remotely connect to each of these machines and you have PowerShell remoting enabled and available on each. Adding to our script, I'll use Invoke-Command to remotely invoke the Malwarebytes installer using the appropriate silent install switches.

$computers = 'PC1','PC2','PC3'
foreach ($computer in $computers) {
    Copy-Item -Path C:\MalwareBytesInstaller -Destination "\\$computer\c$"
    Invoke-Command -ComputerName $computer -ScriptBlock { C:\MalwareBytesInstaller\}Mbam-setup.exe /SILENT /NORESTART }

This should get MalwareBytes installed on each of the computers we've targeted. However, we can't be sure until we check.

Related Article: How To Use PowerShell To Monitor REST APIs

To do this, I've chosen to incorporate a free PowerShell module I've created called SoftwareInstallManager. It can be downloaded directly from Github or via Install-Module SoftwareInstallManager. This is a set of modules that allows you to do lots of different tasks around software deployments. One of those tasks is finding installed software using the Get-InstalledSoftware command. But to use it, it must be copied to each computer. Since we're already copying the installers over, adding these modules should be no sweat.

$computers = 'DC'
foreach ($computer in $computers) {
    Copy-Item -Path C:\MalwareBytesInstaller -Destination "\\$computer\c$" -Recurse -Force
    Copy-Item -Path C:\SoftwareInstallManager -Destination "\\$computer\c$" -Recurse -Force
    Invoke-Command -ComputerName $computer -ScriptBlock {
        C:\MalwareBytesInstaller\mb3-setup-consumer- /SILENT /NORESTART
        Import-Module C:\SoftwareInstallManager\\SoftwarInstallManager.psd1
        if (Get-InstalledSoftware | where { $_.Name -match 'MalwareBytes' }) {
                ComputerName = (hostname)
                Result = $true
        } else {
                ComputerName = (hostname)
                Result = $false
    } | Select ComputerName,Result

At this point, my script is going to return an object for each computer after Malwarebytes is installed indicating if it was successful or not.

ComputerName Result
------------ ------
PC1            False
PC2            True
PC3            True

And there you have it. You've succesfully installed MalwareBytes on all targeted machines. 

Topics: IT insights

Leave a Reply

Your email address will not be published. Required fields are marked *


Adam Bertram is a 20-year veteran of IT. He’s currently an automation engineer, blogger, independent consultant, freelance writer, author, and trainer. Adam focuses on DevOps, system management, and automation technologies as well as various cloud platforms. He is a Microsoft Cloud and Datacenter Management MVP and efficiency nerd that enjoys teaching others a better way to leverage automation.

Free Trials

Getting started has never been easier. Download a trial today.

Download Free Trials

Contact Us

Let us know how we can help you. Focus on what matters. 

Send us a note

Subscribe to our Blog

Let’s stay in touch! Register to receive our blog updates.