Public/Test-P1Prerequisites.ps1
function Test-P1Prerequisites { <# .Synopsis Test if prerequisites of PlannerOne are installed on the machine. .Description Look for a list a features that must be installed. Use Install parameter to force installation of missing features. .Parameter Install Force installation of missing features. .Example # Test prerequisites and install missing features. Test-P1Prerequisites -Install #> [cmdletbinding()] param ( [switch] $Install = $false ) Process { Import-Module servermanager $featureNames = ('Web-Server', 'Web-Mgmt-Console', 'Web-Request-Monitor', 'Web-Windows-Auth', 'Web-Asp-Net45', 'Web-Net-Ext45', 'Web-ISAPI-Filter', 'Web-ISAPI-Ext', 'NET-WCF-HTTP-Activation45', 'NET-Framework-45-ASPNET') Write-Verbose "Checking PlannerOne's prerequisites..." $features = Get-WindowsFeature $featureNames $missingFeatures = ($features | Where-Object InstallState -ne Installed) if ($missingFeatures.Count -eq 0) { Write-Verbose 'No missing features! Ready for PlannerOne!' } else { if ($Install) { Write-Verbose 'Installing missing features' Add-WindowsFeature $missingFeatures | Out-Null $features = Get-WindowsFeature $featureNames } else { Write-Warning 'Something is missing. Run the command again with -Install to fullfill prerequisites.' } } return $features } } |