Have some simple script:
$sql = Get-ChildItem -Path "C:\files\" -Filter *.sql
In C:/files/ can be:
1. No file. (my issue)
One file (test.sql)
Multiple files. (test1.sql , test2.sql , etc)
For 3 i'm using if ($sql.Count -gt 1 )
and its working fine.
2 - is not so relevant.
1st one is a problem - do I have any way (method property) to check and get error or "Exit 1" if file is not present at all at source? (without any if/else "magic") Now it's putting path string into $sql variable, when there are no any *.sql file in folder.