Script Execution File Example
In this example we are creating a policy to deny running a batch or ps1 file, which the policy targets through a secondary file filter.
This example is for a Windows endpoint, but the policy can be created in the same way for a macOS system.
Creating the Policy
-
Navigate to Computer Groups | Windows Computers.
-
Select Application Policies.
-
Click Create Policy.
-
In the policy wizard select Controlling, click Next Step.
-
In the policy wizard select Block, click Next Step.
-
In the policy wizard select Notify and Block, click Next Step.
-
In the policy wizard select Script, click Next Step.
-
In the policy wizard select File Upload.
-
On the Upload a File modal, Click Choose File.
-
Select the file(s) you wish to be targeted. For this example we are first uploading a test.bat and then test.ps1 file. You need to run through the upload and manage application steps twice, once for each file you are uploading.
-
Click Upload File.
-
On the Manage Application dialog, check File Name.
Select more details like the File Path or the Hash, if you want to make this policy more specific.
-
Click Create Filter.
-
Click Next Step.
-
-
On the Finalize the Policy page, enter a name for your new policy. The policy will be created with a default priority of 10, since it is a deny and notify policy.
-
Click Create Policy.
The policy wizard added based on the selected file uploads and the file inventory that was executed 4 types of application targets:
- Command Processor (cmd.exe)
- Powershell (powershell.exe)
- Scripting Host (cscript.exe)
- Scripting Host (wscript.exe)
A secondary file filter was added under Inclusions, identifying two specific file filters for the test.bat and test.ps1 files.
Verifying the Policy Works
-
Add a test.bat file with a simple Hello World command to your system.
-
Create a new text file and add
CopyECHO OFF
ECHO Hello WorldPAUSE -
Save the file as test.bat.
-
-
With your policy set to active, double-click the test.bat file.
The policy triggers the specified message action:
-
With your policy set to inactive, verify via Agent Utility that the update was received and the policy was removed:
-
Double-click the test.bat file.
The batch file is executed and Hello World is printed to the cmd.exe output window.