Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:39:18+00:00 2026-06-04T02:39:18+00:00

I am a complete newbie at powershell. What I need is a powershell script

  • 0

I am a complete newbie at powershell. What I need is a powershell script that can automate the process of installing IIS7 or above. I have certain configurations to be made to the role services. Any help in this regard is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:39:20+00:00Added an answer on June 4, 2026 at 2:39 am

    I found the following blog useful , with certain changes from using help i was able to install IIS from power shell with custom role services.I have the code here and the link to the blog is:

    http://www.ithassle.nl/2010/09/powershell-script-to-install-and-configure-iis7-5/#codesyntax_1

    # --------------------------------------------------------------------
    # Checking Execution Policy
    # --------------------------------------------------------------------
    #$Policy = "Unrestricted"
    $Policy = "RemoteSigned"
    If ((get-ExecutionPolicy) -ne $Policy) {
      Write-Host "Script Execution is disabled. Enabling it now"
      Set-ExecutionPolicy $Policy -Force
      Write-Host "Please Re-Run this script in a new powershell enviroment"
      Exit
    }
    
    # --------------------------------------------------------------------
    # Define the variables.
    # --------------------------------------------------------------------
    $InetPubRoot = "D:\Inetpub"
    $InetPubLog = "D:\Inetpub\Log"
    $InetPubWWWRoot = "D:\Inetpub\WWWRoot"
    
    # --------------------------------------------------------------------
    # Loading Feature Installation Modules
    # --------------------------------------------------------------------
    Import-Module ServerManager 
    
    # --------------------------------------------------------------------
    # Installing IIS
    # --------------------------------------------------------------------
    Add-WindowsFeature -Name Web-Common-Http,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Http-Logging,Web-Request-Monitor,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Performance,Web-Mgmt-Console,Web-Mgmt-Compat,RSAT-Web-Server,WAS -IncludeAllSubFeature
    
    # --------------------------------------------------------------------
    # Loading IIS Modules
    # --------------------------------------------------------------------
    Import-Module WebAdministration
    
    # --------------------------------------------------------------------
    # Creating IIS Folder Structure
    # --------------------------------------------------------------------
    New-Item -Path $InetPubRoot -type directory -Force -ErrorAction SilentlyContinue
    New-Item -Path $InetPubLog -type directory -Force -ErrorAction SilentlyContinue
    New-Item -Path $InetPubWWWRoot -type directory -Force -ErrorAction SilentlyContinue
    
    # --------------------------------------------------------------------
    # Copying old WWW Root data to new folder
    # --------------------------------------------------------------------
    $InetPubOldLocation = @(get-website)[0].physicalPath.ToString()
    $InetPubOldLocation =  $InetPubOldLocation.Replace("%SystemDrive%",$env:SystemDrive)
    Copy-Item -Path $InetPubOldLocation -Destination $InetPubRoot -Force -Recurse
    
    # --------------------------------------------------------------------
    # Setting directory access
    # --------------------------------------------------------------------
    $Command = "icacls $InetPubWWWRoot /grant BUILTIN\IIS_IUSRS:(OI)(CI)(RX) BUILTIN\Users:(OI)(CI)(RX)"
    cmd.exe /c $Command
    $Command = "icacls $InetPubLog /grant ""NT SERVICE\TrustedInstaller"":(OI)(CI)(F)"
    cmd.exe /c $Command
    
    # --------------------------------------------------------------------
    # Setting IIS Variables
    # --------------------------------------------------------------------
    #Changing Log Location
    $Command = "%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.logfile.directory:$InetPubLog"
    cmd.exe /c $Command
    $Command = "%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralBinaryLogFile.directory:$InetPubLog"
    cmd.exe /c $Command
    $Command = "%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralW3CLogFile.directory:$InetPubLog"
    cmd.exe /c $Command
    
    #Changing the Default Website location
    Set-ItemProperty 'IIS:\Sites\Default Web Site' -name physicalPath -value $InetPubWWWRoot
    
    # --------------------------------------------------------------------
    # Checking to prevent common errors
    # --------------------------------------------------------------------
    If (!(Test-Path "C:\inetpub\temp\apppools")) {
      New-Item -Path "C:\inetpub\temp\apppools" -type directory -Force -ErrorAction SilentlyContinue
    }
    
    # --------------------------------------------------------------------
    # Deleting Old WWWRoot
    # --------------------------------------------------------------------
    Remove-Item $InetPubOldLocation -Recurse -Force
    
    # --------------------------------------------------------------------
    # Resetting IIS
    # --------------------------------------------------------------------
    $Command = "IISRESET"
    Invoke-Expression -Command $Command
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Complete C# newbie here, so cut me some slack. I have this application that
I'm a complete newbie in ruby but I can feel that this code can
Complete newbie researching Rails. Can Rails be used with a read-only schema that doesn't
I'll need to preface this with the fact that I am a complete newbie
I'm a complete newbie to VB.NET, how can I test if a dataset has
I am complete newbie in mod_rewrite , and I have been going through some
I will begin by saying that I'm a complete newbie as far as AppleScript
I'm a complete Phonegap newbie so go easy on me if you can :)
I am a complete newbie to SSIS. I have a c#/sql server background. I
I'm a complete newbie when it comes to servers, so I need some help.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.