Thank you for your interest in contributing to the AD Replication Manager project! This document provides guidelines and instructions for contributing.
Project Author: Adrian Johnson adrian207@gmail.com
- Code of Conduct
- Getting Started
- How to Contribute
- Development Guidelines
- Testing Requirements
- Documentation Standards
- Pull Request Process
- Reporting Bugs
- Suggesting Enhancements
- Contact
We are committed to providing a welcoming and inspiring community for all. Please be respectful and professional in all interactions.
- ✅ Use welcoming and inclusive language
- ✅ Be respectful of differing viewpoints and experiences
- ✅ Gracefully accept constructive criticism
- ✅ Focus on what is best for the community
- ✅ Show empathy towards other community members
- ❌ Trolling, insulting/derogatory comments, and personal or political attacks
- ❌ Public or private harassment
- ❌ Publishing others' private information without permission
- ❌ Other conduct which could reasonably be considered inappropriate
- PowerShell: 5.1+ or 7+ (7+ recommended for parallel processing)
- Git: For version control
- Active Directory Module:
Install-WindowsFeature RSAT-AD-PowerShell - Test Environment: Access to a test AD environment with multiple DCs
- Visual Studio Code (recommended) with PowerShell extension
-
Fork the Repository
# Fork via GitHub UI, then clone your fork git clone https://github.com/YOUR-USERNAME/Repl.git cd Repl
-
Create a Branch
git checkout -b feature/your-feature-name # or git checkout -b bugfix/issue-number-description -
Install Development Tools
# Install PSScriptAnalyzer for linting Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -Force # Install Pester for testing (if not already installed) Install-Module -Name Pester -MinimumVersion 5.0 -Scope CurrentUser -Force
-
Verify Setup
# Run existing test suite .\Test-ADReplManager.ps1 -TestDCs "DC01","DC02" # Run PSScriptAnalyzer Invoke-ScriptAnalyzer -Path .\Invoke-ADReplicationManager.ps1
We welcome various types of contributions:
| Type | Examples |
|---|---|
| Bug Fixes | Fix issues, resolve errors, improve stability |
| Features | New functionality, enhancements, optimizations |
| Documentation | Improve docs, add examples, fix typos |
| Tests | Add test cases, improve coverage |
| Performance | Optimize code, reduce execution time |
| Refactoring | Code cleanup, improve maintainability |
# ✅ GOOD: PascalCase for functions
function Get-ReplicationSnapshot {
param(
[Parameter(Mandatory = $true)]
[string]$DomainController
)
}
# ❌ BAD: lowercase or camelCase
function get_replication_snapshot {
param($dc)
}# ✅ GOOD: Comprehensive validation
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[ValidateScript({ Test-Path $_ })]
[string]$Path,
[ValidateSet('Audit', 'Repair', 'Verify')]
[string]$Mode = 'Audit',
[ValidateRange(1, 32)]
[int]$Throttle = 8
)
# ❌ BAD: No validation
param($Path, $Mode, $Throttle)# ✅ GOOD: Specific error handling
try {
$result = Get-ADReplicationFailure -Target $dc -ErrorAction Stop
} catch [Microsoft.ActiveDirectory.Management.ADServerDownException] {
Write-Warning "DC unreachable: $dc"
return
} catch {
Write-Error "Unexpected error: $_"
throw
}
# ❌ BAD: Silent continuation
$result = Get-ADReplicationFailure -Target $dc -ErrorAction SilentlyContinue# ✅ GOOD: Pipeline-friendly streams
Write-Verbose "Processing DC: $dc"
Write-Information "Found $count issues"
Write-Warning "DC01 is degraded"
Write-Error "Failed to connect to DC02"
# ❌ BAD: Write-Host everywhere
Write-Host "Processing DC: $dc" -ForegroundColor Yellow# ✅ GOOD: Wrap all changes with ShouldProcess
function Invoke-ReplicationFix {
[CmdletBinding(SupportsShouldProcess = $true)]
param([string]$DC)
if ($PSCmdlet.ShouldProcess($DC, "Force replication sync")) {
& repadmin /syncall $DC 2>&1
}
}
# ❌ BAD: No WhatIf support
function Invoke-ReplicationFix {
param([string]$DC)
& repadmin /syncall $DC
}- ✅ No PSScriptAnalyzer warnings (run
Invoke-ScriptAnalyzerbefore committing) - ✅ Comment complex logic (why, not just what)
- ✅ Use meaningful variable names (
$domainControllernot$dc1) - ✅ Keep functions focused (single responsibility principle)
- ✅ Avoid magic numbers (use named constants)
- ✅ Use parameter splatting for long parameter lists
# In Invoke-ReplicationFix function, add to switch statement:
'NewIssueType' {
$action.Method = 'CustomFix'
if ($PSCmdlet.ShouldProcess($DC, "Apply custom fix for $($issue.Description)")) {
try {
# Your fix logic here
$result = Invoke-CustomFix -DC $DC -ErrorAction Stop
$action.Success = $true
$action.Message = "Custom fix applied successfully"
Write-RepairLog -Severity 'Information' `
-Message "Applied custom fix to $DC" `
-DC $DC
}
catch {
$action.Success = $false
$action.Message = "Custom fix failed: $_"
Write-RepairLog -Severity 'Error' `
-Message "Failed to apply custom fix to $DC: $_" `
-DC $DC
}
}
else {
$action.Skipped = $true
$action.Message = "User declined custom fix"
}
}
# In Find-ReplicationIssues function, add detection:
if ($snapshot.CustomMetric -gt $threshold) {
$allIssues += [PSCustomObject]@{
DC = $snapshot.DC
Category = 'NewIssueType'
Severity = 'Medium'
Description = "Custom metric exceeded threshold"
Detail = "Value: $($snapshot.CustomMetric)"
Actionable = $true
Timestamp = Get-Date
}
}Every code change MUST include tests:
# Add test case to Test-ADReplManager.ps1
Describe "New Feature Tests" {
It "Should handle new scenario" {
$result = .\Invoke-ADReplicationManager.ps1 `
-Mode Audit `
-DomainControllers "DC01" `
-YourNewParameter "Value"
$result | Should -Not -BeNullOrEmpty
$LASTEXITCODE | Should -Be 0
}
It "Should validate new parameter" {
{
.\Invoke-ADReplicationManager.ps1 `
-Mode Audit `
-DomainControllers "DC01" `
-YourNewParameter "InvalidValue"
} | Should -Throw
}
}# Run full test suite
.\Test-ADReplManager.ps1 -TestDCs "DC01","DC02"
# Run PSScriptAnalyzer
Invoke-ScriptAnalyzer -Path .\Invoke-ADReplicationManager.ps1
# Test WhatIf functionality
.\Invoke-ADReplicationManager.ps1 -Mode Repair -DomainControllers DC01,DC02 -WhatIf
# Test with Verbose
.\Invoke-ADReplicationManager.ps1 -Mode Audit -DomainControllers DC01,DC02 -Verbose- ✅ New functions: 100% test coverage
- ✅ Modified functions: Test all affected code paths
- ✅ Bug fixes: Add regression test
- ✅ Error handling: Test both success and failure cases
- ✅ Parameters: Test validation rules
When contributing, update relevant documentation:
| Change Type | Documentation to Update |
|---|---|
| New Feature | README.md, docs/API-REFERENCE.md, CHANGELOG.md |
| Bug Fix | CHANGELOG.md, docs/TROUBLESHOOTING-GUIDE.md (if applicable) |
| Parameter Change | README.md, docs/API-REFERENCE.md, docs/MIGRATION-GUIDE.md |
| New Function | docs/API-REFERENCE.md, inline help comments |
| Performance | README.md (benchmarks), CHANGELOG.md |
Per docs/DOCUMENTATION-STANDARDS.md:
# Your Document Title
**Version:** 1.1
**Last Updated:** YYYY-MM-DD
**Author:** Adrian Johnson <adrian207@gmail.com>
**Contributors:**
- Your Name <your-email@example.com> - Contribution description
**Classification:** Internal Use
---All functions must include comment-based help:
function Get-YourFunction {
<#
.SYNOPSIS
Brief description of what the function does.
.DESCRIPTION
Detailed description with examples.
.PARAMETER ParameterName
Description of the parameter.
.EXAMPLE
Get-YourFunction -ParameterName "Value"
Description of what this example does.
.OUTPUTS
System.Object
Description of return value/object.
.NOTES
Author: Your Name <your-email@example.com>
Date: YYYY-MM-DD
#>
param(
[Parameter(Mandatory = $true)]
[string]$ParameterName
)
# Function implementation
}- Code follows PowerShell style guidelines
- All tests pass (
Test-ADReplManager.ps1) - No PSScriptAnalyzer warnings
- Documentation is updated
- CHANGELOG.md is updated
- Commit messages are clear and descriptive
Use conventional commits:
type(scope): brief description
Detailed description if needed
- Bullet points for multiple changes
- Reference issues: Fixes #123, Closes #456
Types:
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Code formatting (no functional changes)refactor: Code restructuring (no functional changes)perf: Performance improvementtest: Adding or updating testschore: Maintenance tasks
Examples:
git commit -m "feat(repair): add automatic DC restart for critical failures"
git commit -m "fix(audit): handle null replication metadata correctly"
git commit -m "docs(api): add examples for Get-ReplicationSnapshot"
git commit -m "perf(parallel): optimize throttle mechanism for PS7+"-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request via GitHub UI
-
Fill out the PR template:
## Description Brief description of changes ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Documentation update ## Testing - [ ] Tested in lab environment - [ ] All tests pass - [ ] No PSScriptAnalyzer warnings ## Checklist - [ ] Code follows style guidelines - [ ] Documentation updated - [ ] CHANGELOG.md updated - [ ] Tests added/updated ## Related Issues Fixes #123
- Expect feedback and be prepared to make changes
- Address all review comments
- Keep the discussion professional and constructive
- Update documentation if requested
- Squash commits if requested before merge
- Delete your feature branch
- Pull latest changes from main
- Celebrate! 🎉
- Check existing issues: Search GitHub Issues
- Verify it's a bug: Test in a clean environment
- Collect information: Error messages, logs, environment details
**Describe the Bug**
Clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Run command: `.\Invoke-ADReplicationManager.ps1 ...`
2. With parameters: `-Mode Audit -DomainControllers DC01,DC02`
3. See error: `...`
**Expected Behavior**
What you expected to happen.
**Actual Behavior**
What actually happened.
**Screenshots/Logs**
If applicable, add screenshots or log excerpts.
**Environment:**
- OS: [e.g., Windows Server 2022]
- PowerShell Version: [e.g., 7.4.0]
- AD Forest/Domain: [e.g., contoso.com]
- DC Count: [e.g., 5 DCs]
**Additional Context**
Any other context about the problem.
**Error Messages**
```powershell
# Paste full error messages hereRelated Configuration
- Mode: Audit/Repair/Verify/AuditRepairVerify
- Scope: Forest/Site/DCList
- Other relevant parameters
---
## 💡 Suggesting Enhancements
### Enhancement Request Template
```markdown
**Is your feature request related to a problem?**
Clear and concise description of the problem. Ex. "I'm always frustrated when [...]"
**Describe the solution you'd like**
Clear and concise description of what you want to happen.
**Describe alternatives you've considered**
Alternative solutions or features you've considered.
**Use Cases**
Describe specific scenarios where this would be useful.
**Implementation Ideas**
If you have ideas on how to implement this, share them!
**Additional Context**
Any other context, screenshots, or examples about the feature request.
**Would you be willing to implement this?**
- [ ] Yes, I can submit a PR
- [ ] No, but I can help test
- [ ] No, just suggesting
Adrian Johnson
📧 Email: adrian207@gmail.com
🔗 GitHub: @adrian207
- GitHub Issues: For bugs and feature requests
- Pull Requests: For code contributions
- Discussions: For questions and general discussions
- Email: For private/security concerns
Contributors will be recognized in:
- Project README.md (Contributors section)
- CHANGELOG.md (for significant contributions)
- Documentation (for doc contributions)
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for considering contributing to the AD Replication Manager project! Your contributions help make this tool better for the entire Active Directory admin community.
Copyright © 2025 Adrian Johnson. All rights reserved.