PolicyStore.ImportPolicy Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Import a single policy from the given XML reader. The reader should be previously created by a supported Export method. The imported Policy is also created in the PolicyStore on the server.
public Microsoft.SqlServer.Management.Dmf.Policy ImportPolicy (System.Xml.XmlReader xmlReader, Microsoft.SqlServer.Management.Dmf.ImportPolicyEnabledState importEnabledState, bool overwriteExistingPolicy, bool overwriteExistingCondition);
member this.ImportPolicy : System.Xml.XmlReader * Microsoft.SqlServer.Management.Dmf.ImportPolicyEnabledState * bool * bool -> Microsoft.SqlServer.Management.Dmf.Policy
Public Function ImportPolicy (xmlReader As XmlReader, importEnabledState As ImportPolicyEnabledState, overwriteExistingPolicy As Boolean, overwriteExistingCondition As Boolean) As Policy
Parameters
- xmlReader
- XmlReader
The XML reader to import from.
- importEnabledState
- ImportPolicyEnabledState
The Policy.Enabled flag will be set based on this enum value. The exception is if the policy's execution mode is Check on Schedule but there is no schedule information associated with the policy, in which case the policy is automatically disabled and its execution mode is reset to None.
- overwriteExistingPolicy
- Boolean
If true, then if a Policy of the same name already exists in the Store then it will be overwritten.
- overwriteExistingCondition
- Boolean
If true, then if any Condition associated with the Policy, either directly or through a TargetSet, already exists in the Store then it will be overwritten. Otherwise the existing condition will remain unchanged and the imported policy will use the pre-existing condition rather than the version in the XmlReader.
Returns
The Policy object imported. If the XML reader fails to validate properly or is missing it will throw an exception.