Just a quick post today following on from previous posts invoking methods off the back of infostore queries.
$SessionMgr = New-Object -com ("CrystalEnterprise.SessionMgr") $EnterpriseSession = $SessionMgr.Logon("developmentish","password55","boxiserver01","Enterprise") $InfoStore = $EnterpriseSession.Service("","InfoStore") $InfoObjects = $InfoStore.Query("Select * From CI_INFOOBJECTS Where SI_RECURRING = 1 and SI_NAME = 'My Report Recurring Instance Name'") $InfoObjects | ForEach { $_.DeleteNow() }
Like before, lines 1 2 and 3 of the script are connecting to a session and invoking an infostore service.
The next line see’s us using a query where we search for SI_RECURRING=1 meaning a recurring instance and SI_NAME = ‘My Report Recurring Instance Name’, the name of my recurring instance.
Once my query returns the objects, we just loop through the results using a ForEach loop and execute the DeleteNow() Method.
This should delete any recurring instances that have the same name of the specified one in the query.
Be sure to always include the instance name in the query as this code is pretty dangerous… not including a name will delete ALL recurring instances on your Business Objects system!!!
Enjoy!