Last active
April 19, 2021 16:08
-
-
Save MovGP0/7eba920d537138c119756478be6f3165 to your computer and use it in GitHub Desktop.
Administrate IIS via Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://adamtheautomator.com/powershell-iis/ | |
New-Item -ItemType Directory -Name 'MyWebsite' -Path 'C:\inetpub\wwwroot'; | |
New-IISSite ` | |
-Name 'MyWebsite' ` | |
-PhysicalPath 'C:\inetpub\wwwroot\MyWebsite'; | |
New-IISSiteBinding ` | |
-Name 'MyWebsite' ` | |
-BindingInformation "*:443:" ` | |
-CertificateThumbPrint "D043B153FCEFD5011B9C28E186A60B9F13103363" ` | |
-CertStoreLocation "cert:\LocalMachine\Webhosting" ` # private key must be located here | |
-Protocol https; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://adamtheautomator.com/powershell-iis/ | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; | |
Install-PackageProvider -Name NuGet -Force | |
Install-Module -Name 'WebAdministration' -Scope AllUsers; # manage app pools | |
Install-Module -Name 'IISAdministration' -Scope AllUsers; # manage sites and binding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://adamtheautomator.com/powershell-iis-2/ | |
# virtual folder to manage IIS | |
Set-Location IIS:\ | |
# create app pool | |
New-Item -Path IIS:\AppPools\MyAppPool | |
Set-ItemProperty -Path IIS:\AppPools\MyAppPool -Name managedRuntimeVersion -Value ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$newAppPool = New-WebAppPool -Name 'MyAppPool'; | |
$newAppPool.AutoStart = "true"; | |
# ... | |
$newAppPool | Set-Item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment