I need to run a BAT file once the file is available in Azure Data lake Storage - Gen 1. I have the PowerShell script which does the folder check from my C:\Temp, but I need this to be changed to Azure Data lake storage path location.
Instead of C:\Temp I use AzureRmDataLakeStoreItem
, but facing errors in this.
Below is the PS Script:
Param (
#[string]$Path = "C:\Temp"
[string]$Path = "Test-AzureRmDataLakeStoreItem -AccountName "aruntesting1" -Path "/MyFiles/test.csv" "
)
### Look for any files from the path mentioned above
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $Path
$watcher.Filter = "*.*"
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true
### DEFINE ACTIONS AFTER AN EVENT IS DETECTED
$action = {
$A = Start-Process -FilePath C:\Users\arsivana\Desktop\Arun\Project\xyz\test.bat -Wait -passthru;$a.ExitCode
}
### Events to be watched
Register-ObjectEvent $watcher "Created" -Action $action
Register-ObjectEvent $watcher "Changed" -Action $action
Register-ObjectEvent $watcher "Deleted" -Action $action
Register-ObjectEvent $watcher "Renamed" -Action $action
while ($true) {sleep 2}
Test-AzureRmDataLakeStoreItem
is used to check if a file exists in the account. If file exists, it returnstrue
. Otherwise, it returnsfalse
. So I think you can use the script to trigger$result = Test-AzureRmDataLakeStoreItem -Account $account -Path $path -PathType File if($result){ Start-Process }
. – Jim Xu