Polling the existence of a file with PowerShell
Sometimes you run into a situations where a given task spawns a separate thread and completes it’s work on that separate thread. Eg: sending a bit XMLA to SQL Server Analysis Services with Microsoft.AnalysisServices.Deployment.exe and then waiting for the processing to be completed. Anyway, here is a simple function that will wait untill a given file exists:
function WaitForFile($File) {
while(!(Test-Path $File)) {
Start-Sleep -s 10;
}
}