Recently I had the requirement to install IIS + some features on Windows 7 machines using the application model. After some searching this was fairly easy to accomplish using Dism and a script detection method. Let’s do this step by step.
1. Create a new Application and select “Manually specify the application information”
2. Fill out the application information and application catalog metadata pages and click next to go to the Deployment types page.
3. Click Add on the deployment type page to create a new DT.
4. Select “Script Installer” and “Manually specify the deployment type Information” and click next
5. Give your Deployment type a name and click next.
6. Leave content location empty and set the following as installation program (depends on the feature you want to install, to find a list with windows features you can use the following command: Dism.exe /Online /Get-features):
DISM.exe /Online /Enable-Feature /FeatureName: <NameOftheFeatureToEnable>
In my example it will be the following:
DISM.exe /Online /Enable-Feature /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-RequestFiltering /FeatureName:IIS-StaticContent /FeatureName:IIS-ManagementConsole /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerRole /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-HttpErrors /FeatureName:IIS-HttpLogging /FeatureName:IIS-HttpRedirect
7. On the detection method page select “Use a custom script to detect the presence of this deployment type” and click edit to add the script
8. Select PowerShell and paste a script similar to mine (change or remove feature names to detect to match your scenario).
You can download the example script here : FeatureDetection.zip
9. Configure the User Experience, Requirements (maybe limit the OS here) and Dependency settings to match you scenario.
10. Click next a few time to confirm the creation of the Deployment type and the application
11. Deploy and test.
Till next time
PS: If anyone has a better script to perform the detection feel free to share it