If you run a shell script, please don't ignore messages it writes into console - both errors and information messages. Otherwise you end up where you are - with no idea what happened. In addition, you can change the level of verbosity and you can use a Powershell debugger to run the script step by step and easily observe all variables.
If the file was created but not written into, then something failed after the line with New-Item $filePath -ItemType file -Force.