Version

2.0.0

Author

Stephen Valdinger

Downloads

10

Tags

PowerShellUniversal

Created

01/06/2026

๐Ÿ„ PowerShell Universal Herd Management App

A comprehensive cattle management application built with PowerShell Universal, designed to streamline livestock tracking, weight monitoring, health records, and performance analytics for cattle operations.

๐Ÿ“‹ Overview

Herd Manager is a web-based application that provides ranchers and livestock managers with powerful tools to track and analyze their cattle herd. Built on PowerShell Universal Dashboard, it offers an intuitive interface for managing all aspects of cattle operations from a single platform.

๐Ÿ“š Table of Contents

โœจ Key Features

๐Ÿฎ Cattle Management

  • Comprehensive Animal Profiles: Track individual animals with tag numbers, names, breed, gender, birth dates, origin farm, and current location
  • Farm Integration: Link cattle to farm records for origin and ownership tracking
  • Location Tracking: Manage cattle across 6 pens, quarantine area, and pasture
  • Status Tracking: Monitor animal status (Active, Sold, Deceased, Transferred)
  • CSV Import: Bulk import cattle records from CSV files
  • Searchable Database: Quick search and filter capabilities across all cattle records
  • Dynamic Dropdowns: Smart form fields that adapt based on available farm data

๐Ÿก Farm Management

  • Farm Registry: Maintain complete farm/ranch contact information
  • Origin Tracking: Mark farms as cattle origins for specialized filtering
  • Contact Management: Store addresses, phone numbers, emails, and contact persons
  • Owner Tracking: All farms available for cattle ownership assignment
  • Smart Dropdowns: Origin Farm dropdown shows only origin farms; Owner dropdown shows all farms
  • Active/Inactive Status: Manage farm lifecycle without data loss
  • Edit Capabilities: Update farm information including origin status anytime

โš–๏ธ Weight Management

  • Weight Recording: Log weight measurements with dates and measurement methods
  • Weight History: View complete weight history for each animal with trend visualization
  • Automatic Calculations: Track weight gain over time
  • Multiple Units: Support for pounds (lbs) and kilograms (kg)

๐Ÿ“ˆ Rate of Gain Analysis

  • Average Daily Gain (ADG): Calculate and track ADG between any two weight measurements
  • Historical Tracking: View complete ROG calculation history for performance analysis
  • Period Comparisons: Compare performance across different time periods
  • Automated Calculations: Compute total gain, days between measurements, and daily averages

๐Ÿฅ Health Records

  • Medical History: Track vaccinations, treatments, veterinary visits, and observations
  • Medication Tracking: Record medications, dosages, and administration dates
  • Cost Tracking: Monitor veterinary and treatment expenses
  • Due Date Reminders: Track next vaccination or treatment due dates
  • Overdue Alerts: Automatic notifications for overdue health events

๐Ÿฝ๏ธ Feed Records

  • Daily Feed Tracking: Record daily feed mix quantities (haylage, silage, high moisture corn)
  • Feed History: View complete feeding history with searchable records
  • Total Calculations: Automatic calculation of total feed pounds per day
  • Notes Support: Add contextual notes for each feeding record

๐Ÿ“Š Reporting & Analytics

  • Individual Animal Reports: Comprehensive per-animal reports with complete history
  • Performance Summaries: Current weight, starting weight, total gain, and average ADG
  • Print-Friendly Reports: Generate printable reports for record-keeping
  • Data Visualization: Charts and graphs for weight trends and performance metrics

๐Ÿ”” Notifications Dashboard

  • Centralized Alerts: View all important notifications in one place
  • Overdue Health Events: Immediate visibility of past-due vaccinations and treatments
  • Weight Check Reminders: Alerts for cattle needing weight measurements
  • Upcoming Events: Color-coded display of events by urgency (red: โ‰ค7 days, orange: โ‰ค14 days, blue: >14 days)

๐Ÿ’ฐ Accounting & Invoicing

  • Multi-Cattle Invoicing: Create invoices for single or multiple cattle on one invoice
  • Invoice Generation: Create professional invoices with automatic cost calculations
  • Cost Tracking: Combine feeding costs (days ร— daily rate) and health costs (veterinary expenses)
  • Line Item Detail: Each animal on multi-cattle invoices shows individual costs and subtotals
  • Invoice Management: Search, view, and print invoices in a clean, professional format
  • Payment Terms: NET 30 payment terms with automatic due date calculation
  • Print-Ready Invoices: Professional invoice layout with company branding and contact information
  • Cost Breakdown: Detailed itemization of feeding costs and health/veterinary expenses per animal
  • Owner Billing: Associate cattle with farm owners for accurate billing

๐Ÿ› ๏ธ Technical Stack

  • Platform: PowerShell Universal Dashboard v5
  • Database: SQLite with optimized schema and indexes
  • Language: PowerShell 7
  • UI Framework: Material-UI components via Universal Dashboard
  • Data Access: PSSQLite module for database operations

๐Ÿ“ท Screenshots

Below are some screenshots of the application

  • Homepage

Herd Manager Homepage

  • Cattle Management

Cattle Management

  • Weight Management

Weight Management

  • Health Records

Health Records

More screenshots available in the screenshots folder.

๐Ÿ“ Project Structure

PowerShellUniversal.Apps.HerdManager/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ PowerShellUniversal.Apps.HerdManager/
โ”‚       โ”œโ”€โ”€ dashboards/
โ”‚       โ”‚   โ””โ”€โ”€ HerdManager/
โ”‚       โ”‚       โ”œโ”€โ”€ HerdManager.ps1              # Main dashboard configuration
โ”‚       โ”‚       โ””โ”€โ”€ pages/
โ”‚       โ”‚           โ”œโ”€โ”€ Homepage.ps1             # Dashboard home page
โ”‚       โ”‚           โ”œโ”€โ”€ Notifications.ps1        # Alerts and reminders
โ”‚       โ”‚           โ”œโ”€โ”€ CattleManagement.ps1     # Cattle CRUD operations
โ”‚       โ”‚           โ”œโ”€โ”€ WeightManagement.ps1     # Weight recording and history
โ”‚       โ”‚           โ”œโ”€โ”€ HealthRecords.ps1        # Health tracking
โ”‚       โ”‚           โ”œโ”€โ”€ FeedRecords.ps1          # Daily feed tracking
โ”‚       โ”‚           โ”œโ”€โ”€ Farms.ps1                # Farm management
โ”‚       โ”‚           โ”œโ”€โ”€ RateOfGain.ps1           # ROG calculations
โ”‚       โ”‚           โ”œโ”€โ”€ AnimalReport.ps1         # Individual animal reports
โ”‚       โ”‚           โ”œโ”€โ”€ Accounting.ps1           # Invoice management
โ”‚       โ”‚           โ”œโ”€โ”€ Invoice.ps1              # Invoice display page
โ”‚       โ”‚           โ””โ”€โ”€ Reports.ps1              # Herd-wide analytics
โ”‚       โ”œโ”€โ”€ functions/
โ”‚       โ”‚   โ””โ”€โ”€ public/
โ”‚       โ”‚       โ”œโ”€โ”€ Add-CattleRecord.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Add-WeightRecord.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Add-Invoice.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Add-Farm.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Get-Farm.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Update-Farm.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Calculate-RateOfGain.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Get-AllCattle.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Get-CattleById.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Get-Invoice.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Get-RateOfGainHistory.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Get-WeightHistory.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ Initialize-HerdDatabase.ps1
โ”‚       โ”‚       โ”œโ”€โ”€ New-UDHerdManagerApp.ps1
โ”‚       โ”‚       โ””โ”€โ”€ Update-CattleRecord.ps1
โ”‚       โ”œโ”€โ”€ data/
โ”‚       โ”‚   โ”œโ”€โ”€ Database-Schema.sql              # Complete database schema
โ”‚       โ”‚   โ””โ”€โ”€ HerdManager.db                   # SQLite database
โ”‚       โ”œโ”€โ”€ PowerShellUniversal.Apps.HerdManager.psm1
โ”‚       โ”œโ”€โ”€ PowerShellUniversal.Apps.HerdManager.psd1
โ”‚       โ””โ”€โ”€ .universal/
โ”‚           โ””โ”€โ”€ dashboards.ps1                   # PSU dashboard registration
โ””โ”€โ”€ tests/                                       # Test files (if applicable)

๐Ÿ—„๏ธ Database Schema

Core Tables

  • Cattle: Animal profiles with demographics, location, status, owner, and daily feeding rate
  • WeightRecords: Complete weight measurement history
  • RateOfGainCalculations: Computed performance metrics
  • HealthRecords: Medical history, treatments, and associated costs
  • FeedRecords: Daily feed mix recordings
  • Invoices: Invoice tracking with feeding costs, health costs, and payment terms

Views

  • CattleWithLatestWeight: Quick access to current animal weights
  • RecentRateOfGain: Latest performance calculations

Indexes

Optimized indexes on frequently queried fields for fast performance

๐Ÿš€ Installation

Prerequisites

  • PowerShell 7 or later
  • PowerShell Universal (licensed or trial)
  • PSSQLite PowerShell module

Setup Steps

  1. Clone the Repository

    git clone https://github.com/steviecoaster/PowerShellUniversal.Apps.HerdMgr.git
    cd PowerShellUniversal.Apps.HerdMgr
    
  2. Import the Module

    Import-Module .\src\PowerShellUniversal.Apps.HerdManager\PowerShellUniversal.Apps.HerdManager.psd1
    
  3. Initialize Database (if starting fresh)

    Initialize-HerdDatabase
    
  4. Register with PowerShell Universal

    • Copy the module to your PSU modules directory, or
    • Use the .universal\dashboards.ps1 configuration
    • Restart PowerShell Universal service
  5. Access the Dashboard

    • Navigate to: http://localhost:5000/herdmanager (or your PSU URL)

    In-app Help

    • The full Usage Guide is available inside the application under the Help menu (Help โ†’ Usage Guide) once the module is installed/reloaded.

๐ŸŽจ Features in Detail

Smart Date Handling

  • Automatic date format conversion (MM/dd/yyyy HH:mm:ss)
  • CAST AS TEXT in SQL queries prevents parsing errors
  • Consistent date storage across all tables

Location Management

  • 8 location options: Pen 1-6, Quarantine, Pasture
  • Track animal movements over time
  • Filter and sort by location
  • Quick location updates via edit modal

Print Functionality

  • CSS @media print rules for clean printouts
  • Hides navigation and buttons
  • Optimized layout for paper
  • Professional-looking reports

Responsive UI

  • Material-UI design system
  • Color-coded status indicators
  • Sortable and searchable tables
  • Modal dialogs for forms
  • Toast notifications for feedback

Data Validation

  • Required field enforcement
  • Type validation (dates, numbers, enums)
  • Unique constraints (tag numbers, feed dates)
  • SQL parameter binding prevents injection

Accounting & Billing Workflow

  1. Setup: Add Owner and PricePerDay to cattle records
  2. Track Costs: Record health events with associated costs in HealthRecords
  3. Generate Invoice:
    • Select animal from dropdown
    • Set start and end dates (defaults to purchase date and current date)
    • System automatically calculates:
      • Days on feed
      • Feeding costs (Days ร— Price per day)
      • Health costs (Sum of all health record costs)
      • Total cost
  4. Search Invoices: Find invoices by invoice number
  5. View/Print: Open invoices in new tab with professional print-ready layout
  6. Payment Terms: NET 30 with automatic due date calculation

๐Ÿ”ง Configuration

Database Path

Configured in module: $script:DatabasePath = Join-Path $PSScriptRoot 'data\HerdManager.db'

PowerShell Universal Settings

Edit .universal\dashboards.ps1:

$app = @{
    Name        = "Herd Manager"
    BaseUrl     = '/herdmanager'
    Module      = 'PowerShellUniversal.Apps.HerdManager'
    Command     = 'New-UDHerdManagerApp'
    AutoDeploy  = $true
    Environment = 'PowerShell 7'
}

๐Ÿงช Development

Adding New Features

  1. Create function in functions\public\ or functions\private\
  2. Export public functions in .psd1 manifest
  3. Add page in dashboards\HerdManager\pages\
  4. Register page in HerdManager.ps1 pages array
  5. Add navigation menu item if needed

Database Changes

  1. Update data\Database-Schema.sql
  2. Run ALTER TABLE commands on existing database
  3. Update affected views and functions
  4. Test data migration on sample data

Migrations included

  • src\PowerShellUniversal.Apps.HerdManager\data\Migrate-AddSystemInfo.ps1 - adds the SystemInfo table and seeds a default row
  • src\PowerShellUniversal.Apps.HerdManager\data\Migrate-AddSystemInfoEstablished.ps1 - adds the Established column to SystemInfo (if missing)

Note: After running migrations that change function parameters, restart PowerShell Universal so the runspace picks up the updated code (or copy the module into the installed modules directory and restart the service).

Testing

  • Test all CRUD operations after changes
  • Verify date handling in forms and tables
  • Check calculated fields (ADG, totals)
  • Validate print layouts
  • Ensure modal dialogs function correctly

Running unit tests

  • Run all tests: Invoke-Pester -Script tests -PassThru
  • Run the SystemInfo/Established tests only: Invoke-Pester -Script tests\Set-SystemInfo.Established.Tests.ps1 -PassThru

System Settings (UI and CLI)

  • The app provides a System Settings page (Settings -> System Settings) to store farm-level metadata (Farm Name, Address, Default Currency/Culture, Notes, and Established).
  • The "Established" field is intentionally simple: the UI accepts a 4-digit year (e.g. 2000) and you may also provide a date string (e.g. 2000-01-01) or pass a DateTime from the CLI.
    • If you provide a year it is stored as January 1st of that year (e.g. 2000 -> 2000-01-01).
    • The form normalizes values and will accept array-wrapped values (as some UI controls return arrays).

CLI examples:

# Set by year
Set-SystemInfo -Established 2000

Set by date string

Set-SystemInfo -Established '2000-05-06'

The function also accepts array-wrapped values (UI can send arrays)

Set-SystemInfo -Established @('2001')

Troubleshooting

  • Error "Cannot convert the System.Object[] value ... to type System.DateTime" when saving Established: this can happen when a DatePicker-style control returns an array instead of a single value. The System Settings UI now uses a simple year textbox and the CLI Set-SystemInfo function unwraps arrays and normalizes the value.

Deploying changes to a running PowerShell Universal

  • After changing exported functions (for example, adding or removing parameters), you must copy the updated module files to the installed modules directory and restart the PowerShell Universal service so the running runspace picks up the new signatures.
  • A helper script is provided at src/tools/Sync-InstalledModule.ps1 to copy the module to the installed path and optionally restart the service:
.\src\tools\Sync-InstalledModule.ps1 -RestartService

If you prefer not to restart the service, you can re-import the module in the target runspace (for development/testing) with:

Import-Module -Force "C:\Path\To\PowerShellUniversal.Apps.HerdManager.psd1"

๐Ÿ“ Notes

Date Format Considerations

  • SQLite stores dates as TEXT
  • Application uses MM/dd/yyyy HH:mm:ss format
  • CAST AS TEXT in queries prevents PSSQLite auto-conversion errors
  • Always use -As PSObject with Invoke-UniversalSQLiteQuery

Performance Tips

  • Indexes on CattleID, TagNumber, dates
  • Views pre-calculate common joins
  • Pagination on large tables (15-20 items per page)
  • Dynamic loading with New-UDDynamic for data refresh

Common Issues

  • Dates not displaying: Add CAST AS TEXT to SQL query
  • Location not showing: Check view includes Location column
  • Form not saving: Verify SqlParameters match @Param names in query
  • Modal not opening: Check Show-UDModal syntax and element IDs

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

๐Ÿ“ž Support

For issues, questions, or suggestions:

  • Open an issue on GitHub
  • Check existing documentation
  • Review PowerShell Universal docs

Installation Options

Install within the PowerShell Universal v5 admin console. More Info

PowerShell Universal Gallery

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet.

PS > Install-PSResource PowerShellUniversal.Apps.HerdManager

Version History

Version Published
2.0.0 01/06/2026
1.3.0 01/06/2026
1.2.0 01/06/2026
1.1.0 01/03/2026
1.0.0 01/03/2026