Morning all.I am trying to run script to get Translog details. The script works fine in ISE and produces report as expected. Produces excel report etc.When it runs in an agent job it fails with the following error:Executed as user: XXXXXX. A job step received an error at line 56 in a PowerShell script. The corresponding line is '$logInfo = $db.LogFiles | Select Name, FileName, Size,UsedSpace'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'The following exception was thrown when trying to enumerate the collection: "An exception occurred while executing a Transact-SQL statement or batch.". '. Process Exit Code -1. The step failed.This is part of that script.$intRow++ $logInfo = $db.LogFiles | Select Name, FileName, Size, UsedSpace If ($loginfo.UsedSpace / $loginfo.Size * 100 -gt 50) { $dbname = $db.Name $Sheet.Cells.Item($intRow,2) = $dbname $Sheet.Cells.Item($intRow,3) = ($logInfo.Size / 1024) $Sheet.Cells.Item($intRow,4) = ($logInfo.UsedSpace / 1024) $Sheet.Cells.Item($intRow,5) = ($loginfo.UsedSpace / $loginfo.Size * 100) $Sheet.Cells.Item($intRow,5).Interior.ColorIndex = 3 } else { $dbname = $db.Name $Sheet.Cells.Item($intRow,2) = $dbname $Sheet.Cells.Item($intRow,3) = ($logInfo.Size / 1024) $Sheet.Cells.Item($intRow,4) = ($logInfo.UsedSpace / 1024) $Sheet.Cells.Item($intRow,5) = ($loginfo.UsedSpace / $loginfo.Size * 100) $Sheet.Cells.Item($intRow,5).Interior.ColorIndex = 14 } }I am doing anything wrong there ?Confused over how it works fine in ISE but fails as a SQL agent job.Any advice appreciated.
↧