I recently upgraded SQL Server from Windows 2008 R2 & SQL Server 2008 R2 to Windows 2012 R2 & SQL Server 2014 SP1. One of the sql agent jobs fails to run. The job runs a PowerShell script to script sql agent jobs to disk. The job fails with an error:
SSPI handshake failed with error code 0x8009030c
If I RDP to the server and run the PS script in ISE with the SQL Server Agent service creds, it works.
Any ideas?
Here's the PS script:
param([String]$ServerName)
$OutputFolder = "\\backupfolder\sqlbackups\sqlservername\SQLAgentJobs"
#Load the SQL Server SMO Assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
#Create a new SqlConnection object
$objSQLConnection = New-Object System.Data.SqlClient.SqlConnection
Try
{
$objSQLConnection.ConnectionString = "Server=$ServerName;Integrated Security=SSPI;"
$objSQLConnection.Open() | Out-Null
$objSQLConnection.Close()
}
Catch
{
$errText = $Error[0].ToString()
Write-Host $errText
}
$DoesFolderExist = Test-Path $OutputFolder
$null = if (!$DoesFolderExist){MKDIR "$OutputFolder"}
$srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" $ServerName
foreach($job in $srv.JobServer.Jobs)
{
$job_name = $job.Name
$job.Script() | out-file "$OutputFolder\$job_name.sql"
}