Also, the script fails to run as a normal command
/usr/bin/pwsh /path/to/script
I have other PowerShell scripts that run absolutely fine in the above manner.
It is Just this script that fails because this PowerShell script calls multiple other Powershell scripts.
I think this might be the reason.