Datasource login error when running script with Task Scheduler

I am trying to run a Powershell script using Task Scheduler. The script uses a Logical account with an encrypted password file. If run manually, I am prompted to login to the connection client. I can dismiss the client without logging in and the script runs successfully, but if run with task scheduler the script fails with the following error:

Error: [Error 55515: Invalid user name and password combination.]

This is strange since the same password file is used when run manually or through the task scheduler. Here is the code for logging in I use:

If(Test-Path $PWPsswdFilePath){

    $SecurePassword = Get-SecureStringFromEncryptedFile -FileName E:\PowerShell\Pswd\Refresh_Geo_PWFiles_pw.txt

} else {

    Save-SecureStringToEncryptedFile -FileName E:\PowerShell\Pswd\Refresh_Geo_PWFiles_pw.txt -prompt "enter password to encrypt and store"

    $SecurePassword = Get-SecureStringFromEncryptedFile -FileName E:\PowerShell\Pswd\Refresh_Geo_PWFiles_pw.txt


if (New-PWLogin -DatasourceName $datasource -UserName $pwuser -Password $SecurePassword -NonAdminLogin){


Hoping someone may have some experience with this and has found a workaround.  I saw a post suggesting rolling back to an older version of ProjectWise on the Server (*.*.*.280). I am considering this however not sure how long the version will be supported and I'd rather know I am using the latest version.


Mike Robertson