Export-DbaInstance error on AgentServer #7747
Unanswered
acappelletti
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi I got an error during execution of...
Mode LastWriteTime Length Name
-a---- 31/08/2021 15:28 4214 sp_configure.sql
-a---- 31/08/2021 15:28 364 customererrors.sql
-a---- 31/08/2021 15:28 534 serverroles.sql
-a---- 31/08/2021 15:28 1138 logins.sql
-a---- 31/08/2021 15:28 1359 dbmail.sql
-a---- 31/08/2021 15:28 3121 regserver.xml
-a---- 31/08/2021 15:28 395 backupdevices.sql
-a---- 31/08/2021 15:28 3913 servertriggers.sql
-a---- 31/08/2021 15:28 32238 databases.sql
-a---- 31/08/2021 15:28 153191 policymanagement.sql
-a---- 31/08/2021 15:28 4123 resourcegov.sql
-a---- 31/08/2021 15:28 14901 extendedevents.sql
AVVISO: [15:28:37][Export-DbaScript] Failure on XXXXXXXX | System.Management.Automation.MethodInvocationException: Eccezione durante la chiamata di "EnumScript" con "1" argomento/i: "Script failed for Job
'129EFE82-0209-4678-9B9D-711B2BF34C4A'. " ---> Microsoft.SqlServer.Management.Smo.FailedOperationException: Script failed for Job '129EFE82-0209-4678-9B9D-711B2BF34C4A'. ---> System.NullReferenceException:
Riferimento a un oggetto non impostato su un'istanza di oggetto.
in Microsoft.SqlServer.Management.Smo.Agent.Job.GetJobScriptingScript(StringBuilder createQuery, ScriptingPreferences sp)
in Microsoft.SqlServer.Management.Smo.Agent.Job.ScriptCreate(StringCollection queries, ScriptingPreferences sp)
in Microsoft.SqlServer.Management.Smo.SqlSmoObject.ScriptCreateInternal(StringCollection query, ScriptingPreferences sp, Boolean skipPropagateScript)
in Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObject(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
in Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreate(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
in Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObjects(IEnumerable
1 urns) in Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptUrns(List
1 orderedUrns)in Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable
1 urns) in Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List
1 urns, ISmoScriptWriter writer)in Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithListWorker(DependencyCollection depList, SqlSmoObject[] objects, Boolean discoveryRequired)
in Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects, Boolean discoveryRequired)
--- Fine della traccia dello stack dell'eccezione interna ---
in Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects, Boolean discoveryRequired)
in Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(Urn[] urns, SqlSmoObject[] objects)
in Microsoft.SqlServer.Management.Smo.Scripter.Script(Urn[] urns, SqlSmoObject[] objects)
in CallSite.Target(Closure , CallSite , Object , Object )
--- Fine della traccia dello stack dell'eccezione interna ---
in System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
in Export-DbaScript(Closure , FunctionContext )
-a---- 31/08/2021 15:28 20741 sqlagent.sql
-a---- 31/08/2021 15:28 5851 replication.sql
I undestood is something related to SQL SERVER AGENT data, 'cause using the second cmd (below)
I have no errors... but I missed Jobs scripts or better into "sqlagent.sql" there are rows of data but not related to JOBs (operator, etc...)
My fix is to run 4 commands for each category presents in JOB like... but how can I dynamically get the same result?
Is it something related to my machine?
Alen , Italy
Get-DbaAgentJob -SqlInstance localhost | Where-Object Category -eq "REPL-LogReader" | Export-DbaScript -FilePath "C:\dbatools\AgentJobs.sql"
Get-DbaAgentJob -SqlInstance localhost | Where-Object Category -eq "REPL-Checkup" | Export-DbaScript -FilePath "C:\dbatools\AgentJobs.sql" -Append
Get-DbaAgentJob -SqlInstance localhost | Where-Object Category -eq "Database Maintenance" | Export-DbaScript -FilePath "C:\dbatools\AgentJobs.sql" -Append
Get-DbaAgentJob -SqlInstance localhost | Where-Object Category -eq "Ad-hoc DBA" | Export-DbaScript -FilePath "C:\dbatools\AgentJobs.sql" -Append
Beta Was this translation helpful? Give feedback.
All reactions