Home Forums Programming Powershell File not found error when calling CreateTextFile RE: File not found error when calling CreateTextFile

  • Here's the error I'm receiving:

    A job step received an error at line 17 in a PowerShell script. The corresponding line is '$file = $fso.CreateTextFile($path,$true)'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Exception calling "CreateTextFile" with "2" argument(s): "Exception from HRESULT: 0x800A004C (CTL_E_PATHNOTFOUND" '.

    I've verified that C:\Test Folder\ exists both in my local C: as well as the C: on the server hosting the databases, yet neither of them is getting recognized by the job. I'm quite new to PowerShell and I'm probably missing something pretty obvious. Any ideas?

    Looks like possibly the SQL Server Agent service account does not have the necessary permissions to that folder. I'd take a look at that.

    Sue