We've recently upgraded to SQL Server 2012 (from SQL Server 2008 R2) on Windows Server 2012 (from Windows Server 2008 R2), and a SQL Server Job Agent job that was previously running without error is now failing.
The job has a Powershell job step:
$ErrorActionPreference = 'Stop' $DateStamp = Get-Date -format "yyyyMMdd" $BizUnit = 'SHB' # Target File directory $BaseDir = '\\MyFileServer\MyDirectory' $Query = "EXEC dbo.usp_MyQuery '$BizUnit'" $TargetFile = "MyTargetFile_" + $BizUnit + "_$DateStamp.xml" $TargetDir = (Join-Path -Path $BaseDir -ChildPath $BizUnit) $Query | Out-File -FilePath (Join-Path -Path $TargetDir -ChildPath $TargetFile) -Force -Encoding "utf8"
When the job is run, it fails with this error message:
A job step received an error at line 14 in a PowerShell script. The corresponding line is '$Query | Out-File -FilePath (Join-Path -Path $TargetDir -ChildPath $TargetFile) -Force -Encoding "utf8"'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Cannot perform operation because operation "ReportWrongProviderType" is invalid. Remove operation "ReportWrongProviderType", or investigate why it is not valid.
I can't find any references to "ReportWrongProviderType" when I search the interwebz. Any ideas on what is wrong with the Out-File call?