Found the root cause of the issue but not sure what would be the fix. Kindly advice
Log when I manually executed the command from DOS this works fine
That's what I've meant.
But again, I'm not a PowerShell expert. Ask in some PowerShell community, or maybe at stackoverflow.com or superuser.com.