I used this script today to install basic authentication on a build server, which did not have basic authentication installed in it.
Please note of the state: Available, Installed as they make two different meanings.
Available says, that the component available in the server, but not installed (not checked in windows roles/features interface).
So to simulate the state of checking the feature “Basic Authentication”, run the script.
Import-Module ServerManager $check = Get-WindowsFeature | Where-Object {$_.Name -eq "Web-Basic-Auth"} if($check){ if($check.InstallState -eq "Available"){ Install-WindowsFeature Web-Basic-Auth | Out-Null } else{ Write-Host "Feature already installed on the server..." } } else{ Write-Host "Feature Web-Basic-Auth not available..." }