Trying to remotely remove publications using ISHRemote Remove-IshPublicationOutput

Hi,

I am writing an ISHRemote script to delete the contents of a folder on our Tridion Docs server.

The plan is to do deletions in this order:

publications, publications folder, root ditamaps, other ditamaps, maps folder, topics, topics folder.

I have started with the following code

$pubsFolder = Get-IshFolder -FolderPath $pubsFolderPath
$ishObjects = Get-IshFolderContent -IShSession $ishSession -IshFolder $pubsFolder
if($ishObjects.length -gt 0)
{
foreach($ishObject in $ishObjects)
{
   Remove-IshPublicationOutput -IshObject $ishObjects -Force
}
}

which executes fine the first time and $ishObjects is empty on second execution. However when I navigate into Tridion Docs webclient, I am still seeing the pre-existing publication object :-|

How is this? Am I doing the removal properly according to ISHRemote?

Any advice appreciated,

Regards,

Ann

  • Hi Ann,

    The integration tests of the ISHRemote library always build up the test data, and at the end of the file clean up any data that they created. See for example https://github.com/sdl/ISHRemote/blob/master/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/PublicationOutput/AddIshPublicationOutput.Tests.ps1

    I'm assuming that you refreshed the UI you were looking into (typically F5 or the Refresh icon on the toolbar). The system is not super aggressive in finding out if objects are removed. After all that is an atypical situation.

    If something went wrong with the API calls, then I assume you got errors. Either errors visible in your ISHRemote execution, or errors in the server-side InfoShareWS*.log file (e.g. C:\InfoShare\Data\Logs\InfoShareWS_20201015.log)

    Can you describe that "pre-existing publication object"? Is it still complete, or are language level or version levels missing? Was it part of a frozen baseline? Any other things you can share?

    Best wishes,
    Dave

  • Forgive me, I am still learning :-) I thought that Remove-IshPublicationOutput -IshObject $ishObjects -Force would remove the actual publication and not the output generated from publishing the publication...so it is removing the output. After removing the publication output I then thought that I would have to explicitly remove the publication object before removing the container folder called Publications...but I didn't. I simply called Remove-IshFolder -FolderPath $pubsFolderPath and it removed the publication object and the containing folder. Is this as expeced?

    So now I am trying to remove the topics from the topics folder as follows:

    $topicsFolderPath = 'General\Import\Topics'
    $topicsFolder = Get-IshFolder -IShSession $ishSession -FolderPath $topicsFolderPath
    $ishObjects = Get-IshFolderContent -IShSession $ishSession -IshFolder $topicsFolder
    if($ishObjects.length -gt 0)
    {
    foreach($ishObject in $ishObjects)
    {
    Remove-IshDocumentObj -IShSession $ishSession -IshObject $ishObjects -Force
    }
    }

    but I am getting the following error on the call to Remove-IshDocumentObj

    Remove-IshDocumentObj : Cannot convert 'System.Object[]' to the type 'Trisoft.ISHRemote.Objects.Public.IshObject' required by parameter
    'IshObject'. Specified method is not supported.
    At <path>\CleanScript.ps1:60 char:63
    + ... -IshDocumentObj -IShSession $ishSession -IshObject $ishObjects -Force
    + ~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Remove-IshDocumentObj], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Trisoft.ISHRemote.Cmdlets.DocumentObj.RemoveIshDocumentObj

    Any advice appreciated,

    Regards,

    Ann