November 21, 2016 at 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.
March 30, 2017 at 12:05 pm
pgraves - Monday, November 21, 2016 8:17 AMHi,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.
March 31, 2017 at 1:10 am
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"
March 31, 2017 at 3:52 am
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.
March 31, 2017 at 4:09 am
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.
March 31, 2017 at 11:15 am
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