Knowledge Base
v5.14.1
Search this version
How to send a file to ICAP server for testing the functionalities using the powershell script?
Copy Markdown
Open in ChatGPT
Open in Claude
Check Your Version:
This article applies to all MetaDefender ICAP Server releases deployed on Windows systems.
The script shown below is made to specifically work with text files only (using the .txt format). Using different files formats will result in the script failing.
Create a powershell script with the content below and save it as icap_win.ps1
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
param (
[string]$icapServer = "127.0.0.1", #ICAP server IP
[int]$icapPort ="1344", # ICAP default port
[string]$icapService = "/OMSScanReq-AV", # ICAP service name
[string]$filePath = "" # Path to the file
)
# Read file content
$fileContent = [System.IO.File]::ReadAllBytes($filePath)
$fileSize = $fileContent.Length
$chunkSize = [Convert]::ToString($fileSize, 16) # Convert size to hexadecimal
# Define ICAP Headers
$icapRequest = "REQMOD icap://$icapServer`:$icapPort$icapService ICAP/1.0`r`n"
$icapRequest += "Host: $icapServer`r`n"
$icapRequest += "User-Agent: PowerShell-ICAP-Client`r`n"
$icapRequest += "Encapsulated: req-hdr=0, req-body=" + ($fileSize + 4) + "`r`n`r`n"
# Define HTTP Encapsulation (Required by ICAP)
Execute the script following the command
9
1
.\icap_win.ps1 -icapServer <ICAP Server IP> -icapPort <ICAP Port> -filePath <Path to test file>
Example:
.\icap_win.ps1 -icapServer "127.0.0.1" -icapPort 1344 -filePath "D:\eicar.txt"
Support:
If Further Assistance is required, please proceed to log a support case or chatting with our support engineer.
Last updated on
Was this page helpful?
Knowledge Base
Knowledge Base
Configuration & Setup
Error & Troubleshooting