Quantcast
Channel: SQL Server Setup & Upgrade forum
Viewing all articles
Browse latest Browse all 5760

Custom Condition for Policy Based Management

$
0
0

Hopefully this is the correct forum please move if not..

I'm trying to write a custom condition to use in policy based management that will be executed against several servers and report back those that have SQL agent jobs where 'sa' is not the owner.

ExecuteSql('string', 'SELECT
    sv.name AS [Name],
    sv.job_id AS [JobID],
    l.name AS UserName
    FROM
    msdb.dbo.sysjobs_view AS sv
    INNER JOIN [master].[sys].[syslogins] l ON sv.owner_sid = l.sid
WHERE L.name <> ''sa''
    ORDER BY
    sv.[Name] ASC')

I enter the above in the Field with an Operator of = and Value 1 under the Server Facet and it complains that the input string is incorrect.  I also get an error of "Make sure string constants are enclosed in single quotes and facet properties are prefixed with '@' sign."


Viewing all articles
Browse latest Browse all 5760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>