Skip to content

Instantly share code, notes, and snippets.

@guimar86
Last active March 27, 2022 16:33
Show Gist options
  • Save guimar86/331c84d44769d0f92b667de70a196389 to your computer and use it in GitHub Desktop.
Save guimar86/331c84d44769d0f92b667de70a196389 to your computer and use it in GitHub Desktop.

Verify IIS Configuration 2

Print a list of all web features Get-WindowsFeature -Name Web*| Where Installed | Select-Object Name

Set the result list in a variable

$desiredFeatures=@( "web-server", "web-webServer" )

Loop through all these web features to verify IIS configuration

foreach($feature in $desiredFeatures){

if((Get-WindowsFeature $feature).InstallState -ne "Installed"){

  Write-Host "Failed- $feature Not Installed" -Foregroundcolor Red
  break
}else{
  Write-Host "Pass - $feature is installed" -Foregrouncolor Green
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment