Creating a Workflow Report and Placing into Default Container

Someone asked if you could use powershell to generate a workflow status report and save it into the workflow's default container..... yes you can!

Add-Type -Path "D:\Program Files\Hewlett Packard Enterprise\Content Manager\HP.HPTRIM.SDK.dll"
$iseProc = Get-Process -id $pid
$db = New-Object HP.HPTRIM.SDK.Database
$wfs = New-Object HP.HPTRIM.SDK.TrimMainObjectSearch -ArgumentList $db, Workflow
$wfs.SearchString = "all"
$report = New-Object HP.HPTRIM.SDK.Report -ArgumentList $db, "Workflow Report"
$docRt = New-Object HP.HPTRIM.SDK.RecordType -ArgumentList $db, "Document"
foreach ( $wf in $wfs ) 
{
    if ( ([HP.HPTRIM.SDK.Workflow]$wf).DefaultContainer -ne $null ) 
    { 
        $wfc = New-Obect HP.HPTRIM.SDK.TrimMainObjectSearch -ArgumentList $db, Workflow
        $wfc.SearchString = "uri:$(([HP.HPTRIM.SDK.Workflow]$wf).Uri)"
        $pdf = $report.PrintReportToPdf($wfc)
        $pdfRec = New-Object HP.HPTRIM.SDK.Record -ArgumentList $db, $docRt
        $pdfRec.TypedTitle = "Workflow Report"
        $pdfRec.SetDocument($pdf)
        $pdfRec.SetContainer(([HP.HPTRIM.SDK.Workflow]$wf).DefaultContainer)
        $pdfRec.Save()
        $pdfRec.Dispose()
    }
}
$db.Dispose()

Calculating Total Size (Bytes) used by Record Types

Someone on the forums posted a question about how to calculate total volume by record type.  Given that there is little capability to gather this information from the client, I figured I'd share my powershell script.  It's included below!  

Add-Type -Path "D:\Program Files\Hewlett Packard Enterprise\Content Manager\HP.HPTRIM.SDK.dll"
Add-Type -Path "D:\Program Files\Hewlett Packard Enterprise\Content Manager\HP.HPTRIM.Framework.dll"
$iseProc = Get-Process -id $pid
$db = New-Object HP.HPTRIM.SDK.Database
$rtSearch = New-Object HP.HPTRIM.SDK.TrimMainObjectSearch -ArgumentList $db, RecordType
$rtSearch.SearchString = "all"
$rtSearch = [HP.HPTRIM.SDK.ObjectSelector]::SelectMany($iseProc.MainWindowHandle, $rtSearch)
foreach ( $rt in $rtSearch ) 
{
    [long]$totalBytes = 0
    [long]$curRec = 0
    $recs = New-Object HP.HPTRIM.SDK.TrimMainObjectSearch -ArgumentList $db, Record
    $recs.SearchString = "type:$($rt.Uri)"
    foreach ( $rec in $recs ) 
    {
        $curRec++
        Write-Progress -Activity "Inspecting $(([HP.HPTRIM.SDK.RecordType]$rt).Name)" -status "Record $($curRec)" -PercentComplete (($curRec/$recs.Count)*100)
        $totalBytes += ([HP.HPTRIM.SDK.Record]$rec).DocumentSize
        foreach ($rendition in $rec.ChildRenditions) {
            $totalBytes += ([HP.HPTRIM.SDK.RecordRendition]$rendition).Bytes
        }
        foreach ($revision in $rec.ChildRevisions ) {
            $totalBytes += ([HP.HPTRIM.SDK.RecordRevision]$revision).Bytes
        }
    }
    Write-Host "$(([HP.HPTRIM.SDK.RecordType]$rt).Name) Total Size: $($totalBytes)"
	$recs.Dispose()
}
$rtSearch.Dispose()
$db.Dispose()

When you run the powershell script you'll first be prompted to select the record type(s) you want to inspect.  You can either highlight one individual record type, tag multiples, or hit cancel.  If you've selected a record type the script will iterate each sequentially and inspect the electronic object, any renditions, and all revisions.

2017-09-11_18-27-04.png

A handy progress bar will indicate the progress through each record type....

2017-09-11_18-27-04.png

Once it's all done with the calculations you'll see the output in the window...

2017-09-11_18-27-04.png

IDOL Firewall Rules

The HPE technical support folks released a new support tip regarding firewall rules for IDOL.  I like the way they've written it up and how they've explained it.  Though what they left out was how to go about actually implementing the firewall rules.  

I took the information they provided and placed it within a powershell script.  Obviously others may need to tweak it to suit their environment, but it should help most sites accomplish the task without much effort.  Just run the script via an elevated powershell command prompt (or remotely via CIM).

 

$rule = Get-NetFirewallRule -Name "HPE_CM_IDOL_SERVER"
if ( $rule -eq $null ) 
{
    New-NetFirewallRule -Name HPE_CM_IDOL_SERVER -DisplayName "HPE Content Manager IDOL Server" -Description "Enables ports 9000-9002,9070" -Protocol TCP -LocalPort 9000-9002,9070 -RemotePort 9000-9002,9070
    Write-Host "IDOL Server rule created"
} else {
    Write-Host "IDOL Server rule already exists"
}
 
$rule = Get-NetFirewallRule -Name "HPE_CM_IDOL_CONTENT1"
if ( $rule -eq $null ) 
{
    New-NetFirewallRule -Name HPE_CM_IDOL_CONTENT1 -DisplayName "HPE Content Manager IDOL Content 1" -Description "Enables ports 9100-9102" -Protocol TCP -LocalPort 9100-9102 -RemotePort 9100-9102
    Write-Host "IDOL Content 1 rule created"
} else {
    Write-Host "IDOL Content 1 rule already exists"
}