Invoke-PolicyEvaluation returns same result whether or not Policy was violated

  • I am trying to figure out what is wrong with this piece of code. I have a condition that checks the data space used against the max size. The policy looks for data that stays below 90% of max. If it is reaches 90% or more this policy should return a Result of False. The problem I am having is that every database I try returns False whether or not the policy is violated. Evaluating the Policy in SSMS works just fine.

    If any has any ideas, I would really appreciate it.

    $db=gi sqlserver:\sql\D000XXX\default\databases\Northwind

    gci -path SQLSERVER:\SQLPolicy\D000XXX\default\Policies |

    where {$_.Name -eq 'MaxSizeDataFile'} |

    Invoke-PolicyEvaluation -TargetObjects $db |

    ft Result -autosize

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • Try changing this:

    $db=gi sqlserver:\sql\D000XXX\default\databases\Northwind

    to this:

    $db=gi sqlserver:\sql\D000XXX\default

    After seeing how this changes the playing field in terms of what you evaluate policies against you may want to rename your variable too 😉

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply