Getting contents of a publication

I'm trying to read the contents of a publication file. Here's my attempt:

$ishSession = New-IshSession -WsBaseUrl xxx.sdlproducts.com/.../ -ishUserName xxx -ishPassword "xxxx"

$ishSession.DefaultRequestedMetadata = 'All';

$pfolder = Get-IshFolder -FolderPath "\General\_Global\_Resource Library\Tools\Cross Reference Tool\Publications"
$pobjects = Get-IshFolderContent -ishfolder $pfolder
foreach ($pobject in $pobjects)
{
    $pub = Get-IshDocumentObjData -ishobject $pobject -FolderPath "C:\tmp" -Debug
}

$pobject is of type ISHPublication, but Get-IshDocumentObjData generates the following:

Get-IshDocumentObjData : Buffer cannot be null.
Parameter name: array
At line:15 char:12
+ $pub = Get-IshDocumentObjData -ishobject $pobject -FolderPath "C: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-IshDocumentObjData], ArgumentNullException
+ FullyQualifiedErrorId : GetIshDocumentObjData,Trisoft.ISHRemote.Cmdlets.DocumentObj.GetIshDocumentObjData

Parents
  • Hi Dave,

    You are actually pretty close, the key thing is that you should look at PublicationOutputs (so the actual ZIP or PDF or CHM or whatever target of publishing file) while DocumentObj (is about topics, library topics, maps, images, etc).

    I've tested with this pipeline friendly version, where output of the previous cmdlet is passed to the next (without explicit -IshObject usage)

    $fileInfo = Get-IshFolder -BaseFolder Data -FolderTypeFilter @("ISHPublication")  -Recurse |
    Get-IshFolderContent |
    Get-IshPublicationOutputData -FolderPath C:\temp\20210701.ISHRemote

    Theoretically adapting your code, it would look like

    $pfolder = Get-IshFolder -FolderPath "\General\_Global\_Resource Library\Tools\Cross Reference Tool\Publications"
    $pobjects = Get-IshFolderContent -ishfolder $pfolder
    foreach ($pobject in $pobjects)
    {
        $pub = Get-IshPublicationOutputData -ishobject $pobject -FolderPath "C:\tmp" 
    }

    If I may, some remarks

    • $ishSession.DefaultRequestedMetadata = 'All' indicates to retrieve more metadata or actually all metadata of objects, which in this example only slows down Get-IshFolderContent as you are not using it later on, in this sample
    • your returned $pub contains .NET FileInfo objects... so in essence it returns you filenames so you can do something with the downloaded PDFs, ZIPs, etc
    • If you are on ISHRemote v0.13 or higher, than Get-IshFolderContent offers several filter parameters (like latest version only, or languages or custom filter metadata, etc)

    Best wishes,
    Dave ;-)

Reply
  • Hi Dave,

    You are actually pretty close, the key thing is that you should look at PublicationOutputs (so the actual ZIP or PDF or CHM or whatever target of publishing file) while DocumentObj (is about topics, library topics, maps, images, etc).

    I've tested with this pipeline friendly version, where output of the previous cmdlet is passed to the next (without explicit -IshObject usage)

    $fileInfo = Get-IshFolder -BaseFolder Data -FolderTypeFilter @("ISHPublication")  -Recurse |
    Get-IshFolderContent |
    Get-IshPublicationOutputData -FolderPath C:\temp\20210701.ISHRemote

    Theoretically adapting your code, it would look like

    $pfolder = Get-IshFolder -FolderPath "\General\_Global\_Resource Library\Tools\Cross Reference Tool\Publications"
    $pobjects = Get-IshFolderContent -ishfolder $pfolder
    foreach ($pobject in $pobjects)
    {
        $pub = Get-IshPublicationOutputData -ishobject $pobject -FolderPath "C:\tmp" 
    }

    If I may, some remarks

    • $ishSession.DefaultRequestedMetadata = 'All' indicates to retrieve more metadata or actually all metadata of objects, which in this example only slows down Get-IshFolderContent as you are not using it later on, in this sample
    • your returned $pub contains .NET FileInfo objects... so in essence it returns you filenames so you can do something with the downloaded PDFs, ZIPs, etc
    • If you are on ISHRemote v0.13 or higher, than Get-IshFolderContent offers several filter parameters (like latest version only, or languages or custom filter metadata, etc)

    Best wishes,
    Dave ;-)

Children