HOW TO: Setup IIS Web Server in Windows Server 2012 Using PowerShell

Automating IIS setup via PowerShell is a foundational skill for maintaining consistent web environments. While the core steps remain the same, modern Windows Server versions (2019/2022/2025) have introduced the IISAdministration module as the preferred path for automation.

Modern Update (2026): Microsoft now recommends the IISAdministration module over the legacy WebAdministration module. It is built for the PowerShell object pipeline, offering better performance and more reliable transactional commits.

1. Install the Web Server Role

This command installs the base IIS role along with the required management tools for PowerShell control.

Install-WindowsFeature -Name Web-Server -IncludeManagementTools

2. Create an Application Pool

If you are using a Group Managed Service Account (gMSA) for your pool identity, ensure your username ends with a $ (e.g., svc_webapp$).

# Modern IISAdministration method
Import-Module IISAdministration
$poolName = "MyApplicationPool"

# Create the pool
New-IISAppPool -Name $poolName

# Set identity (use gMSA or custom account)
$pool = Get-IISAppPool -Name $poolName
$pool.ProcessModel.IdentityType = "SpecificUser"
$pool.ProcessModel.UserName = "DOMAIN\svc_webapp$"
$pool.ProcessModel.Password = "" # Required blank for gMSA
$pool | Set-IISAppPool

3. Create the Website & SSL Binding

Modern IIS setup utilizes SNI (Server Name Indication), allowing you to host multiple SSL sites on a single IP address.

$siteName = "MyWebSite"
$path = "C:\inetpub\wwwroot\myapp"
$thumbprint = (Get-ChildItem cert:\LocalMachine\My | Where-Object { $_.Subject -like "*CN=mysite.com*" } | Select-Object -First 1).Thumbprint

# Create Site with HTTPS and SNI enabled
New-IISSite -Name $siteName -PhysicalPath $path -BindingInformation "*:80:" 
New-IISSiteBinding -Name $siteName -BindingInformation "*:443:mysite.com" -CertificateThumbPrint $thumbprint -Protocol https -SslFlag "Sni"

Note: Windows Server 2025 has deprecated the legacy IIS 6 Management Console. Ensure your automation scripts do not rely on Web-Lgcy-Mgmt-Console.

Author’s Note: This article reflects my personal professional experience and opinions. While my insights are informed by my professional history, these views are my own and do not represent the official position of my former employer.

About the Author: Jacob Marks is an engineering leader with over 20 years of experience, including a decade at Amazon Web Services (AWS) where he led teams in EC2 Core Platform and the development of the AWS Payment Cryptography service.

Labels

.NET .NET 10 .NET 3.5 Active Directory AD DS Adoption AI AI coding AI Ethics AI Hype Alerts Amazon Cognito Amazon DLM Amazon Q Anthropic AppDomain Architecture Artificial Intelligence Asia Pacific Sydney ASP.net ASPxGridView Audit Readiness Auto Recovery Automation AWS AWS Certified AWS Lambda AWS Payment Cryptography AWS SDK AWS Security Specialty Azure Azure DevOps Server Backup BIG-IP C# Career Growth Cartes Bancaires CB Certificate Bundle Certification Claude Cloud Cloud Certification Cloud Hosting Cloud Security CloudWatch CLR Content Query Cost Optimization Credentials CyberChef Database Defense Industry Deloitte Developer Tools Developers DevEx DevExpress DevOps DISA Disk Space DISM Distributed Systems DoD DoD CC SRG DUKPT EBS EC2 Engineering Engineering Leadership Engineering Management EnPasFltV2 Enterprise Event Receiver Exam F5 Federal IT FedRAMP Fintech FISMA GAC Generative AI GitHub gMSA GovCloud Government Compliance GridView Hardware Security Modules HSM IAM Identity Management IIS Infra Infrastructure as Code IT Tools Jacob Marks JavaScript jQuery Lambda Leadership Linqpad LLM lsass.exe LTM Memory Optimization Mentorship Microsoft Migration Multi-Region Keys NACL Native AOT Network Architecture Networking NIST ODBC Open Source Payment Cryptography Payments PCI Compliance Performance Platform Platform Architecture Power Tools PowerShell Python re:Invent Reachability Analyzer Redshift Relationships List Replace Root Volume SAA-C00 SAP-C00 Security Security Group Serverless SES SharePoint SharePoint 2010 Site Reliability SMTP Snapshot Software Engineering Solutions Architect Solutions Architect Professional SP 2007 SPAWAR SSL STIG Storage Strategy Sydney SysAdmin Team Foundation Server Team Utilities Tech Industry Technical Depth Technology TFS Tools Troubleshooting Upgrade Visual Studio VPC VPC Flow Logs Web Development WebPart WinDirStat Windows Server Windows Server 2025 WinForms