SQL Policy Management - Invoke-PolicyEvaluation - remote policy file path

  • Hi,

    I'm trying to call a number of XML SQL Management Policy files using a remote network path e.g.

    Invoke-PolicyEvaluation -TargetServer "instancename" -Policy "\\servername\policy.xml"

    This results in an XML error:

    Invoke-PolicyEvaluation : File '.....' does not have a valid XML format that can be deserialized to a policy.

    When using a local path or a mapped path it works correctly e.g.

    Invoke-PolicyEvaluation -TargetServer "instancename" -Policy "C:\policy.xml"

    Can anyone explain this error. I really need to use a shared location for storing SQL policy files.

    Any feedback is appreciated.

  • pgraves - Monday, November 21, 2016 8:17 AM

    Hi,I'm trying to call a number of XML SQL Management Policy files using a remote network path e.g.Invoke-PolicyEvaluation -TargetServer "instancename" -Policy "\\servername\policy.xml"This results in an XML error:Invoke-PolicyEvaluation : File '.....' does not have a valid XML format that can be deserialized to a policy.When using a local path or a mapped path it works correctly e.g. Invoke-PolicyEvaluation -TargetServer "instancename" -Policy "C:\policy.xml"Can anyone explain this error. I really need to use a shared location for storing SQL policy files.Any feedback is appreciated.

    Anything on this? I too am having the exact same issue. It makes no sense to me why reading the file from a network share should be any different than reading from a local folder.

  • look at https://docs.microsoft.com/en-us/powershell/sqlserver/sqlserver-module/vlatest/invoke-policyevaluation

    Although the examples there do not use a network share, the Get-ChildItem can get them from there with no issues, and you pipe the file onto Invoke-PolicyEvaluation

    e.g. get-childitem networked_xmlfile|Invoke-PolicyEvaluation -TargetServer "MYCOMPUTER"

    or even
    get-item networked_xmlfile|Invoke-PolicyEvaluation -TargetServer "MYCOMPUTER"

  • frederico_fonseca, thanks for the suggestion.

    In my PowerShell, I went with mapping a local drive to a shared location and referencing the policy files from the new local drive but I don't like the solution.

    Going to try your method.

  • Nope. Policies just can't be read correctly from a shared location.

    Set-Location "\\pathToPolicyfiles"
    get-item "policy.xml" | Invoke-PolicyEvaluation -TargetServer "servername"
    ERROR: does not have a valid XML format that can be deserialized to a policy.

    Back to using a mapped drive for me.

  • does this work? without setting location

    get-item "\\pathToPolicyfiles\policy.xml" | Invoke-PolicyEvaluation -TargetServer "servername"

Viewing 6 posts - 1 through 5 (of 5 total)

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