In this article, you will learn how to use TimeXtender Orchestration to verify that an Excel file is accessible and not locked by another user or process before running a data pipeline that reads from it.
When a user has an Excel file open with unsaved changes, the file is held with an exclusive write lock. Any process that tries to read or open that file will fail. By running this check before the ingest pipeline, Orchestration can alert the right people and prevent the pipeline from running against an inaccessible file.
How It Works
A PowerShell package attempts to open the file with ReadWrite access. If the file is accessible and not locked, it immediately closes the file handle and exits successfully. If the file is locked or unavailable, an exception is thrown, triggering any configured Orchestration failure notifications.
Steps
- Open TimeXtender Orchestration and Data Quality Desktop.
- Right-click Packages in the Object Explorer.
- Select New → PowerShell.
- Give the package a descriptive name, for example: Check Excel File – Sales.xlsx.
- Select an Execution Connection targeting the gateway server that has network access to the file path.
- Enter the following script, replacing the file path with your file's location:
$filePath = 'C:\temp\myfile.xlsx'
try {
$stream = [System.IO.File]::Open($filePath, 'Open', 'ReadWrite', 'None')
$stream.Close()
$stream.Dispose()
Write-Output "[$filePath] File is accessible and not locked. No action needed."
exit 0
} catch {
throw "[$filePath] File is not accessible. Error: $($_.Exception.Message)"
}
- Click Save.
Notes
- The script opens the file with ReadWrite access and no sharing (
FileShare.None). This catches exclusive write locks held by other processes. - To check read-only accessibility — for example, if other processes are allowed to have the file open for reading — replace
'ReadWrite'with'Read'and'None'with'Read'. - Place this package before any Orchestration packages that ingest from the file, so it acts as a gate.
- If the file is on a network share, the path should be the UNC path accessible from the gateway server (e.g.,
\\server\share\file.xlsx).
Reuse with Query Snippets
Save this script as a Query Snippet in TimeXtender Orchestration. You can then reuse it across multiple packages — one per Excel file — by updating the $filePath variable in each instance.