Technical Articles

Review Cloudmersive's technical library.

How to Scan OneDrive Folders for Viruses and Malware in Power Automate
8/28/2023 - Brian O'Neill

floating white checkmark

Power Automate is a steadily growing platform with immense utility. Through simple point-and-click designs, we can make efficient connections between applications, and we can take steps to automate file processing & administration tasks that might’ve once stolen our time away from more important projects.

One of the many hidden benefits we can gain from Power Automate flows is improved redundancy in our file storage security policies. Using the Cloudmersive Virus Scan API in Power Automate, we can easily engage powerful virus scans any time new files enter one (or multiple) target folders in our OneDrive file storage system.

In the below demonstration, we’ll walk through a few simple steps to automate OneDrive folder virus scanning in Power Automate. In just a few minutes, we'll be able to scan dozens of common file types for more than 17 million virus and malware signatures.

1 – Starting from the Power Automate home page, let’s select Create and click on the Automated Cloud Flow option.

1 - select automated cloud flow

In the Build an automated cloud flow window, let’s search for a OneDrive flow trigger called When a File is Created. Once we find it, let’s go ahead and select it, and then let’s click Create to head to the flow diagram page.

2 - when a file is created

2 – On the flow diagram page, let’s configure our trigger step by selecting the folder we want to scan. We can accomplish this by clicking on the folder icon and navigating our OneDrive folder path.

3 - configure trigger step

3 – Now we can incorporate our Cloudmersive Virus Scan Connector action.

Let’s click new step and type Cloudmersive into the search bar. From the list of Cloudmersive connectors below, let’s select the Virus Scan Connector with the blue-green logo.

4 - select cloudmersive virus scan connector

If we haven't yet used this connector, we'll receive a prompt to name our connection and provide our API key at this stage. We can name our connection anything we want, and we can then copy & paste an API key from our Cloudmersive Account Page. Once this information is entered, it'll save automatically for future uses.

From the Virus Scan Connector actions list, let’s select the action called Scan a File for Viruses.

5 - select scan a file for viruses

To configure our request, let’s click on the Input File field and select File Content from the dynamic content window. This content is automatically retrieved when a new file is added to our target folder in OneDrive.

6 - select file content for input file

Our flow is now ready to trigger upon receiving a file in our target folder, retrieve the content of that file, and scan it for 17 million+ virus and malware signatures. When infected files are identified, the API response will return a CleanResult: False value. Clean files will return a CleanResult: True value instead.

4 – There are a variety of steps we can take to handle a scenario where an infected file is identified. The simplest option is to create a condition that takes different actions based on the CleanResult response. Below is one example of a condition that takes no action when clean files are detected and deletes the file outright when virus and malware signatures are identified.

7 - delete file if infected

To test this flow and trigger a CleanResult: True response, we can use any common file type we expect to store in this folder. To trigger a CleanResult: False response safely, we can utilize an inert file threat made available on the EICAR website (this of course depends on permissions/limitations set out in our particular environment).

For more information on how you can use the Cloudmersive Virus Scan API & Cloudmersive Virus Scan Connector to protect your applications and file storage locations, please do not hesitate to reach out to a member of our sales team.

800 free API calls/month, with no expiration

Get started now! or Sign in with Google

Questions? We'll be your guide.

Contact Sales