Automated SQL Server configuration to standardize security, performance, and operational readiness across standalone and high-availability environments.
This PowerShell framework provides a modular approach to applying SQL Server best practices across one or multiple servers. It is designed to automate post-installation hardening, service configuration, storage tuning, connectivity setup, and compliance-related settings in a consistent and repeatable way.
The script detects whether the target environment is standalone or high availability, then executes a controlled sequence of configuration functions against the defined SQL Server nodes. It helps DBAs and system administrators reduce manual configuration effort, avoid inconsistent server builds, and enforce a standard baseline for SQL Server deployments.
The automation covers:
- Static SQL Server port configuration
- SQL client alias creation
- Firewall rule setup
- Local administrator and drive permission assignment
- Windows privileges for SQL service accounts
- SQL Server service account configuration using MSA/gMSA
- SQL Server hardening, including disabling sa, guest access, Browser service, and instance discovery
- Password policy enforcement for SQL logins
- Memory, MAXDOP, TempDB, and file growth optimization
- Service startup and automatic restart configuration
- Trace flags, auditing, error log retention, and default trace setup
- Endpoint creation for messaging or service communication
Key Capabilities
- Environment Detection – Identifies standalone or HA deployments and builds the server execution list automatically.
- Security Hardening – Disables risky defaults such as sa, guest access, SQL Browser, and public access to sensitive extended procedures.
- Service Account Standardization – Applies managed service accounts to SQL Server Engine and Agent services.
- Performance Tuning – Configures SQL memory limits, MAXDOP, cost threshold, TempDB files, and file growth.
- Operational Resilience – Sets SQL services to automatic startup and configures recovery actions after failure.
- Network Readiness – Applies static ports, firewall rules, SQL aliases, and instance visibility controls.
- Compliance Support – Enables audit-related settings such as login auditing, error log retention, password policy enforcement, and trace configuration.
Functions
- Get-EnvironmentType – Detects standalone or HA configuration.
- Configure-StaticPort – Sets a fixed TCP port for the SQL Server instance.
- Configure-ServiceLogonAs – Configures SQL Engine and Agent service accounts.
- Configure-Aliases – Creates SQL Server client aliases.
- Configure-FirewallRules – Opens required SQL Server ports.
- Configure-LocalAdministrator – Grants local admin permissions to defined accounts.
- Configure-DrivePermissions – Applies drive-level permissions for SQL service accounts.
- Configure-WindowsPrivileges – Grants SQL-related Windows privileges.
- Configure-SaDisable – Renames and disables the default sa login.
- Configure-GuestDisable – Revokes guest access from user databases.
- Configure-AdvancedOptions – Applies advanced SQL Server configuration settings.
- Configure-NTLocalSystem – Grants required sysadmin access to system/service accounts.
- Configure-ServiceStartupType – Sets SQL services to automatic startup.
- Configure-ServiceAutoRestart – Enables service recovery after failures.
- Configure-SqlBrowserService – Stops and disables SQL Browser.
- Configure-MemoryLimits – Sets SQL Server memory limits.
- Configure-MaxDopParallelism – Tunes MAXDOP and cost threshold.
- Configure-DefaultDirectories – Sets default data, log, and backup directories.
- Configure-AutoGrowth – Standardizes database file growth settings.
- Configure-TraceFlags – Enables recommended SQL Server trace flags.
- Configure-Endpoint – Creates SQL Server endpoint configuration.
- Configure-TraceAudit – Enables audit and trace-related settings.
- Configure-HideInstance – Hides the SQL Server instance from network discovery.
- Configure-SqlLoginPolicy – Enforces password policy on SQL logins.
- Configure-TempDb – Optimizes TempDB layout and growth settings.
