Author Posts

April 22, 2015 at 6:36 am

I'm trying to automate a standard web server install on 2012 r2. I'm using add-windows feature to install a long list of features/Roles. What is the best way to format without using ' (backtick) to make it easily readable and simple to add/remove items should the default build change?

Thanks

Example:
add-WindowsFeature web-server, Web-Default-Doc, Web-Http-Errors, `
Web-Static-Content,Web-Http-Redirect, Web-Http-Logging, Web-Request-Monitor, `
Web-Stat-Compression, Web-Basic-Auth, Web-Windows-Auth, Web-Net-Ext, Web-Net-Ext45, `
Web-AppInit, Web-ASP, Web-Asp-Net, Web-Asp-Net45, Web-CGI, Web-ISAPI-Ext, Web-ISAPI-Filter, `
Web-IP-Security, Web-CGI, Web-ISAPI-Ext,Web-ISAPI-Filter, Web-Mgmt-Console, Web-Mgmt-Compat, `
Web-Metabase, Web-Scripting-Tools, Telnet-Client, Migration

April 22, 2015 at 6:42 am

One, try just omitting the backtick. After a comma, the shell will usually look for the next piece of data. Or, define the string as an array first, and then pass the array (in a variable) to the parameter.

April 22, 2015 at 7:19 am

I like the array method:

$features = @("Web-Server",
              "Web-Default-Doc", 
              "Web-Http-Errors",
              "Web-Static-Content",
              "Web-Http-Redirect")

Add-WindowsFeature -Name $features -IncludeManagementTools

April 22, 2015 at 12:34 pm

Here's what I've been using:

Get-Content .\IIS.txt | % { Install-WindowsFeature -Name $_ }

and I attached the IIS.txt file I use. It lists the IIS features I'd like to see in a standard IIS build..