Import of XML searches using Powershell

We have a script that creates multiple XML files to send a notification when a security group is modified. We can import these manually in Change Auditor no problem and they work fine. But I cannot find any Powershell cmdlet in Change Auditor Powershell module to import these XML file while this features is implemented in the GUI. Only the Add-CASearch I can see which is not doing what I need. Is there a way to import just like we do in the GUI but using Powershell?

Or maybe there is a folder (hidden) that I am not seeing to copy over these XML?  

We are at a point that for every groups created, there is an authority approver email address attached to it and every time there is a new group, a new alert needs to be created.  The script saves a tons of time, but if we could add the import part to CA in the script, it will help a tons.

Thanks in advance

  • Add-CASearch implements a switch "-XmlSearchDefinition"

    How is this not doing what you need?

    As I recall, you "export" the search definition using Get-CASearchDefinition, tweak it as you need to and the re-import it using Add-CASearch.

  • This is the script and the failed result in red 

    $ChangeAuditorPowershellModuleFile = "C:\Program Files\Quest\ChangeAuditor\Client\ChangeAuditor.PowerShell.dll"
    $ChangeAuditorInstallationName = "default"
    $connection = Connect-CAClient -InstallationName $ChangeAuditorInstallationName
    $XMLFile = Get-Content "C:\Change Auditor Alerts\Alert1.xml"
    
    Add-CASearch –Connection $connection –XmlSearchDefinition $XMLFile –IsPublic –Path Shared\Alertsfolder –Name “My Alert” -PassThru

    "Add-CASearch : Cannot convert 'System.Object[]' to the type 'System.Xml.XmlDocument' required by parameter 'XmlSearchDefinition'. Specified method is not
    supported."

  • Ok, I was able to get this going by adding [xml]  before variable for on the get-content line.  But, it doesn't import all of the fields from the XML as the GUI client does.  It's not importing the email values (ex: toAddress, replyto, CC,BCC) and they well populated in the XML and again, the import feature using the same exact XML works very well using Change Auditor client.  I'm on 7.3 btw

    Here is an example for other that are in the same situation.  The documentation example forgot that part.

    $ChangeAuditorPowershellModuleFile = "C:\Program Files\Quest\ChangeAuditor\Client\ChangeAuditor.PowerShell.dll"
    $ChangeAuditorInstallationName = "default"
    $connection = Connect-CAClient -InstallationName $ChangeAuditorInstallationName
    [xml] $XMLFile = Get-Content "C:\Change Auditor Alerts\Alert1.xml"
    
    Add-CASearch –Connection $connection –XmlSearchDefinition $XMLFile –IsPublic –Path Shared\Alertsfolder –Name “My Alert” -PassThru

  • Your solution makes sense because Get-Content generally imports data as text so if you really need to have it handled as true XML you need to cast your variable as you have done.

    'Would suggest you open a ticket about the non-import of the e-mail fields.