2.0.0
Stephen Valdinger
10
PowerShellUniversal
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
- Overview
- Key Features
- Technical Stack
- Screenshots
- Project Structure
- Database Schema
- Installation
- Features in Detail
- Development
- Testing
- Troubleshooting
- Contributing
- Support
โจ 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
- Cattle Management
- Weight Management
- 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
-
Clone the Repository
git clone https://github.com/steviecoaster/PowerShellUniversal.Apps.HerdMgr.git cd PowerShellUniversal.Apps.HerdMgr -
Import the Module
Import-Module .\src\PowerShellUniversal.Apps.HerdManager\PowerShellUniversal.Apps.HerdManager.psd1 -
Initialize Database (if starting fresh)
Initialize-HerdDatabase -
Register with PowerShell Universal
- Copy the module to your PSU modules directory, or
- Use the
.universal\dashboards.ps1configuration - Restart PowerShell Universal service
-
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.
- Navigate to:
๐จ 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 printrules 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
- Setup: Add Owner and PricePerDay to cattle records
- Track Costs: Record health events with associated costs in HealthRecords
- 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
- Search Invoices: Find invoices by invoice number
- View/Print: Open invoices in new tab with professional print-ready layout
- 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
- Create function in
functions\public\orfunctions\private\ - Export public functions in
.psd1manifest - Add page in
dashboards\HerdManager\pages\ - Register page in
HerdManager.ps1pages array - Add navigation menu item if needed
Database Changes
- Update
data\Database-Schema.sql - Run ALTER TABLE commands on existing database
- Update affected views and functions
- Test data migration on sample data
Migrations included
src\PowerShellUniversal.Apps.HerdManager\data\Migrate-AddSystemInfo.ps1- adds theSystemInfotable and seeds a default rowsrc\PowerShellUniversal.Apps.HerdManager\data\Migrate-AddSystemInfoEstablished.ps1- adds theEstablishedcolumn toSystemInfo(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).
- If you provide a year it is stored as January 1st of that year (e.g.
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-SystemInfofunction 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.ps1to 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:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- 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
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 |