Enterprise-grade automation scripts for Windows, Linux, and SQL Server infrastructure management.
This repository contains 35+ production-tested scripts demonstrating enterprise infrastructure automation across multiple platforms. These scripts showcase real-world operational experience in managing complex, multi-platform environments with a focus on security, reliability, and operational excellence.
- π’ Enterprise Experience - Scripts used in production environments managing 500+ systems
- π Security-First Approach - Hardening, compliance, and least-privilege automation
- βοΈ Cross-Platform Expertise - Windows (PowerShell), Linux (Bash), SQL Server (T-SQL)
- π Operational Excellence - Monitoring, patching, backup, and high-availability operations
- π§ͺ Production Quality - Comprehensive error handling, logging, and documentation
| Category | Description | Scripts |
|---|---|---|
| Active Directory | User lifecycle management, group administration, security policies | 6 scripts |
| Security Hardening | CIS benchmarks, firewall automation, certificate management | 9 scripts |
| System Monitoring | Disk space, event logs, port scanning, service health | 4 scripts |
| SQL Server HA | Availability group operations, failover automation, monitoring | 8 scripts |
| Patch Management | Automated Windows/Linux updates, compliance reporting | 3 scripts |
| System Maintenance | Cleanup operations, file management, backup automation | 5 scripts |
IMPORTANT: All scripts in this repository have been sanitized for public sharing. Company-specific information, credentials, and internal network details have been replaced with placeholders.
- β
Replace all
<YOUR_*>placeholders with your environment values - β
Replace
company.localwith your actual domain - β Never use default/example passwords in production
- β Review and test in non-production environment first
- β Understand what each script does before execution
infrastructure-automation/
βββ powershell/ # Windows automation scripts
β βββ user-management/ # AD user lifecycle (onboarding, offboarding)
β βββ security/ # Security hardening, certificate management
β βββ monitoring/ # System health monitoring
β βββ maintenance/ # Cleanup and maintenance tasks
β βββ device-management/ # Autopilot, device enrollment
β βββ FolderRedirection/ # User profile management
β
βββ bash/ # Linux administration scripts
β βββ security/ # UFW firewall, Ubuntu hardening (CIS/STIG)
β βββ monitoring/ # Port scanning, service health checks
β
βββ sql/ # SQL Server administration
β βββ high-availability/
β βββ failover/ # Availability group failover operations
β βββ monitoring/ # AG health monitoring queries
β
βββ scripts/ # Cross-cutting operations
β βββ backup/ # Backup automation
β βββ patch-management/ # Update deployment and compliance
β
βββ docs/ # Documentation
βββ POWERSHELL.md # PowerShell scripts guide
βββ BASH.md # Linux scripts guide
βββ SQL.md # SQL scripts guide
For PowerShell Scripts:
- PowerShell 5.1+ (Windows) or PowerShell 7+ (cross-platform)
- Active Directory PowerShell module (for AD operations)
- Appropriate permissions (varies by script)
For Bash Scripts:
- Bash 4.0+
- Root or sudo access (for system-level operations)
- Ubuntu/Debian-based system (scripts are tailored for Ubuntu 24.04)
For SQL Scripts:
- SQL Server 2016+ (compatible with 2008R2+)
- VIEW SERVER STATE permission (for monitoring)
- CONTROL SERVER permission (for failover operations)
-
Clone the repository:
git clone https://github.com/unplugged12/infrastructure-automation.git cd infrastructure-automation -
Review scripts before execution:
# PowerShell: View script help Get-Help .\powershell\user-management\New-UserOnboarding.ps1 -Detailed
-
Customize for your environment:
- Replace all placeholders (
<YOUR_*>,company.local, etc.) - Update domain names, IP addresses, and credentials
- Review security settings and adjust for your policies
- Replace all placeholders (
PowerShell - User Onboarding:
# Review the script first
Get-Help .\powershell\user-management\New-UserOnboarding.ps1 -Full
# Run with WhatIf to preview actions
.\powershell\user-management\New-UserOnboarding.ps1 -WhatIf
# Execute (after customization)
.\powershell\user-management\New-UserOnboarding.ps1Bash - Ubuntu Hardening:
# Make executable
chmod +x bash/security/harden_ubuntu24.sh
# Review script contents
less bash/security/harden_ubuntu24.sh
# Execute with sudo
sudo ./bash/security/harden_ubuntu24.shSQL - Availability Group Monitoring:
-- Open in SQL Server Management Studio
-- Run against primary replica
-- File: sql/high-availability/monitoring/ListAvailabilityGroups.sql- Infrastructure Architecture - Design and implementation of multi-platform automation
- Security Governance - Compliance automation (CIS, STIG), security hardening
- High Availability - SQL Server Always On configuration and failover operations
- Operational Excellence - Monitoring, alerting, and proactive maintenance
Windows/Active Directory:
- User lifecycle automation (onboarding, offboarding, modification)
- Group Policy and security baseline enforcement
- Certificate management and PKI operations
- PowerShell DSC and advanced scripting
Linux:
- Security hardening (UFW firewall, fail2ban, AppArmor)
- CIS benchmark automation for Ubuntu
- Service monitoring and health checks
- Bash scripting with error handling
SQL Server:
- Always On Availability Group operations
- Automated failover procedures
- Health monitoring and alerting
- T-SQL stored procedures and automation
- Infrastructure as Code - Scripts version-controlled and repeatable
- Documentation - Comprehensive inline help and README guides
- Testing - Pester tests for PowerShell functions
- Security - Secrets management, least privilege, audit logging
All scripts include comprehensive inline documentation:
- Synopsis - Brief description of purpose
- Description - Detailed functionality explanation
- Parameters - Input parameter documentation
- Examples - Usage examples with explanations
- Notes - Prerequisites, permissions, security considerations
- PowerShell Scripts Guide - Windows automation reference
- Bash Scripts Guide - Linux operations reference
- SQL Scripts Guide - Database administration reference
- SECURITY.md - Security policy and best practices
- CONTRIBUTING.md - Contribution guidelines
Scripts are categorized by operational risk:
- User onboarding/offboarding scripts
- Password hash extraction utilities
- System hardening with external dependencies
- SQL Server failover operations
Guidelines: Test in lab environment, require peer review, document changes
- File deletion/cleanup operations
- Permission modifications
- Firewall configuration changes
- System configuration changes
Guidelines: Test with -WhatIf flag, verify backup exists, review logs
- Monitoring and reporting scripts
- Read-only information gathering
- Health check queries
- Audit log analysis
Guidelines: Safe for direct use, minimal testing required
# View script help
Get-Help .\script.ps1 -Detailed
# Test with WhatIf (dry-run)
.\script.ps1 -WhatIf
# Run with verbose output
.\script.ps1 -Verbose
# Run Pester tests (where available)
Invoke-Pester -Path .\powershell\FolderRedirection\Tests\# Check syntax
bash -n script.sh
# Run with verbose/debug output
bash -x script.sh
# Run with dry-run flag (if supported)
./script.sh --dry-runPowerShell Modules:
# Install required modules
Install-Module ActiveDirectory -Force
Install-Module Microsoft.Graph -ForceLinux Packages:
# Ubuntu/Debian
sudo apt install ufw fail2ban apparmor-utils
# Verify bash version
bash --version # Requires 4.0+Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-script) - Test your changes thoroughly
- Document your code with inline help
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ready-to-use automation for common tasks
- Best practices for security hardening
- Templates for creating custom automation
- Demonstration of automation capabilities
- Examples of infrastructure as code
- Security and compliance automation patterns
- Cross-platform scripting examples
- CI/CD integration patterns
- Infrastructure automation templates
For questions, issues, or feature requests:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
These scripts were developed and refined over 10+ years of enterprise IT operations, managing infrastructure across multiple industries and company sizes.
Technologies: PowerShell, Bash, T-SQL, Active Directory, SQL Server Always On, Ubuntu Server, Windows Server, Azure AD
Built with a focus on security, reliability, and operational excellence.