Skip to content

Instantly share code, notes, and snippets.

@mark05e
Last active January 16, 2025 15:25
Show Gist options
  • Save mark05e/1ca54ad210f38eeea957eeace35793ca to your computer and use it in GitHub Desktop.
Save mark05e/1ca54ad210f38eeea957eeace35793ca to your computer and use it in GitHub Desktop.

Incontact DB Connector Notes

Windows Service Information

function Get-DBCServiceInformation {
    $DisplayName = "Incontact"

    # Check if running PowerShell 5 or earlier
    if ($PSVersionTable.PSVersion.Major -le 5) {
        # Get all services that match the display name using Get-WmiObject
        $services = Get-WmiObject -Class Win32_Service | 
                     Where-Object {$_.DisplayName -like "*$DisplayName*"}
    } else {
        # Get all services that match the display name using Get-CimInstance
        $services = Get-CimInstance -ClassName Win32_Service | 
                     Where-Object {$_.DisplayName -like "*$DisplayName*"}
    }

    # Display the results
    $services | Select-Object -Property Name, DisplayName, PathName, Status
}

# Usage:
Get-DBCServiceInformation

Connection Information

function Get-DBCConnections {
    # Define the process name to track
    $trackProcessName = "*DBCServer*"

    # Get established connections for the specified process
    $establishedConnections = Get-NetTCPConnection | 
        Where-Object {$_.OwningProcess -gt 0} | 
        Select-Object -Property LocalAddress, LocalPort, RemoteAddress, RemotePort, State, 
            @{name='ProcessName';expression={(Get-Process -Id $_.OwningProcess).Path}}, CreationTime

    # Filter connections by process name
    $connectionsToTrack = $establishedConnections | 
        Where-Object {$_.ProcessName -like $trackProcessName}

    # Return the filtered connections
    $connectionsToTrack
}

# Usage:
Get-DBCConnections | Format-Table

Logs Path

C:\Program Files (x86)\inContact\DBConnector\{RegisteredServerInfo}\

Logs Collection

function Copy-LogsToDesktop {
    param (
        [string]$SourceFolderPath = "C:\Program Files (x86)\inContact\DBConnector"
    )

    # Define the desktop path
    $desktopPath = [Environment]::GetFolderPath("Desktop")

    # Get the timestamp
    $timestamp = Get-Date -Format "yyyyMMdd_HHmmss"

    # Create the log folder name
    $logFolderName = "DBConnectorLogs_$env:COMPUTERNAME_$timestamp"

    # Create the full log folder path
    $logFolderPath = Join-Path -Path $desktopPath -ChildPath $logFolderName

    # Create the log folder
    New-Item -Path $logFolderPath -ItemType Directory -Force

    # Copy log files to the log folder
    Get-ChildItem -Path $SourceFolderPath -Filter *.log -Recurse | 
        Copy-Item -Destination $logFolderPath

    # Zip the log folder
    Compress-Archive -Path $logFolderPath -DestinationPath (Join-Path -Path $desktopPath -ChildPath ($logFolderName + ".zip"))

    Write-Host "Logs have been copied and zipped to the desktop."
}

# Usage:
Copy-LogsToDesktop

Resources

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment