Help with formatting

This topic contains 3 replies, has 4 voices, and was last updated by Profile photo of Sam Boutros Sam Boutros 1 year, 6 months ago.

  • Author
  • #24544
    Profile photo of Jared Derby
    Jared Derby

    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?


    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

  • #24545
    Profile photo of Don Jones
    Don Jones

    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.

  • #24548
    Profile photo of Rob Simmers
    Rob Simmers

    I like the array method:

    $features = @("Web-Server",
    Add-WindowsFeature -Name $features -IncludeManagementTools
  • #24558
    Profile photo of Sam Boutros
    Sam Boutros

    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..

You must be logged in to reply to this topic.