Last active
January 18, 2018 20:56
-
-
Save phaniav/b4ba9e04d8aa3c7e857a835d1a386d0a to your computer and use it in GitHub Desktop.
Verify and Install Windows Features and Optional Features
This file contains hidden or 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
function xEnsurePresent-WindowsFeature([string] $FeatureName) | |
{ | |
$gwf = Get-WindowsFeature -Name $FeatureName | |
if($gwf.InstallState -eq 'Installed') | |
{ | |
Write-Host "$FeatureName already Installed" | |
} | |
else | |
{ | |
Write-Host "$FeatureName Installing" | |
Install-WindowsFeature -Name $FeatureName - | |
} | |
} | |
xEnsurePresent-WindowsFeature -FeatureName NET-Framework-45-ASPNET | |
xEnsurePresent-WindowsFeature -FeatureName NET-HTTP-Activation | |
xEnsurePresent-WindowsFeature -FeatureName Web-ASP | |
xEnsurePresent-WindowsFeature -FeatureName Web-Asp-Net | |
xEnsurePresent-WindowsFeature -FeatureName Web-Asp-Net45 | |
function xEnsurePresent-WindowsOptionalFeature([string] $FeatureName) | |
{ | |
$wf = Get-WindowsOptionalFeature -Online -FeatureName $FeatureName | |
if($wf.State -eq 'Enabled') | |
{ | |
Write-Host "$FeatureName already running" | |
} | |
else | |
{ | |
Write-Host "$FeatureName Starting" | |
Enable-WindowsOptionalFeature -Online -FeatureName $FeatureName -NoRestart | |
} | |
} | |
xEnsurePresent-WindowsOptionalFeature -FeatureName IIS-WebServerRole |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment