Help with formatting

Welcome Forums General PowerShell Q&A Help with formatting

This topic contains 3 replies, has 4 voices, and was last updated by

3 years, 10 months ago.

  • Author
  • #24544

    Points: 0
    Rank: Member

    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

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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

    Points: 502
    Helping Hand
    Rank: Major Contributor

    I like the array method:

    $features = @("Web-Server",
    Add-WindowsFeature -Name $features -IncludeManagementTools
  • #24558

    Points: 157
    Helping Hand
    Rank: Participant

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

The topic ‘Help with formatting’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort