• Thanks for your response, unfortunately I have only worked through the GUI so don't understand much of what is in your scripts as they don't appear to match what is created by the 'script' button within the GUI.

    I do have two 'conditions', one for the test I wish to make and one for the databases I wish to exclude. These are referenced in a Policy as you describe. The problem I have is the 'Condition' for the databases I wish to exclude. Currently I have this set to use a 'not like' clause for a single string. When I script this it shows

    Declare @condition_id int

    EXEC msdb.dbo.sp_syspolicy_add_condition @name=N'Exclude databases', @description=N'', @facet=N'Database', @expression=N'<Operator>

    <TypeClass>Bool</TypeClass>

    <OpType>NOT_LIKE</OpType>

    <Count>2</Count>

    <Attribute>

    <TypeClass>String</TypeClass>

    <Name>Name</Name>

    </Attribute>

    <Constant>

    <TypeClass>String</TypeClass>

    <ObjType>System.String</ObjType>

    <Value>%AuditLog2%</Value>

    </Constant>

    </Operator>', @is_name_condition=4, @obj_name=N'%AuditLog2%', @condition_id=@condition_id OUTPUT

    Select @condition_id

    GO

    I can not make out how to change this for a 'NOT IN' condition with an array of database names, which is what I am trying to achieve.