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"
}

TIL: Windows Server 2016 Core

I have not yet seen a CM implementation hosted on a Windows 2016 server, let alone one on server core.  Eventually that will change.  So time to play and see what happens.

As shown in the picture below, server core does not have a desktop.  Also missing are: Taskbar, Windows File Explorer, Control Panel, and the Event Viewer.  It does have a command prompt though.

UI experience in 2016 server core

UI experience in 2016 server core

This should be a clear sign to application administrators that the product administration tasks would not be performed from the server (or at least, that doesn't really fit with the intended use of server core). 

On my test VM I cannot even launch the thick client.  Same for the Enterprise Studio.  Neither presents me with any sort of error message, they just don't launch.  

To effectively use Server Core with Content Manager, I should start doing things remotely. First I need to enable some firewall rules via a powershell session.  These may or may not be needed in your environment.

set-netfirewallrule -name remoteeventlogsvc-in-tcp -Enabled True
set-netfirewallrule -name remoteeventlogsvc-np-in-tcp -Enabled True
set-netfirewallrule -name remoteeventlogsvc-rpcss-in-tcp -Enabled True

Now, from my Windows 10 Workstation, I open the Server Manager and add my server.  

Add Servers Option in Server Manager

Add Servers Option in Server Manager

Next I'll remote onto the server (I used HyperV to connect directly to the server core console, but you'd probably use RDP or a remote PSSession)  and enable the administration of this server by the domain account used to run the CM workgroup service.  I ran "sconfig" and then used option 3 to add in the account.  

2017-09-05_11-42-43.png

Next I install CM using the standard installer.  It would be best to use command-line parameters, but you will see the installer UI on the server if you run it manually.

Running the installer on 2016 server core

Running the installer on 2016 server core

Once installed, it must be configured.  I'm skipping the required steps for local security policy settings, folder structure preparation, and CM firewall rules (do these on your own).  Keep in mind that you should really be doing all of this remotely, via a remote powershell session.  RDP access to the server is truly not needed for any of these tasks.

Configuring the application is as easy as choosing "Open" from a local instance of the Enterprise Studio.  That means installing the studio (and probably the workgroup server itself) on your local machine.  Once launched, you can click the File ribbon, select open, navigate to the server's configuration file, and selecting it.  The Enterprise Studio tells you, in the window's title bar, the current location of the configuration file.

Appearance of Enterprise Studio when remotely managing the instance

Appearance of Enterprise Studio when remotely managing the instance

So now I've got a fully functioning instance of CM on Windows Server Core 2016!   In later posts I'll show how to leverage the Windows Server Manager to monitor the health of the CM instance.  For now, I can increase the total number of servers I have because each will require fewer resources (one of the biggest benefits of the usage of a core server).