Microsoft Internet Information Server (IIS)

Views: 3.6k  |  Created: 08/25/2009

Average Rating: 0
Internet Information Server (IIS) has 1 inventory records, 1 Questions, 1 Blogs and 6 links. Please help add to this by sharing more!

Deployment Tips (3)

Most Common Setup Type
Not Determined
Average Package Difficulty Rating
Rated 4 / 5 (Somewhat Difficult) based on 1 ratings
Most Commonly Reported Deployment Method
Vendor Provided Command Line (answer file driven)
or cancel
5
Note
IIS 7.0 can be installed unattended using one of 3 methods:
-Pkgmgr.exe (Works in Vista, Server 2008, and Server 2008 R2)
-Servermanagercmd.exe (Server 2008 and deprecated in Server 2008 R2) (not available in Vista or Seven)
-ServerManager PowerShell cmdlets (Server 2008 R2 ONLY!!)

In true MS form, MS has turned on the upgrade threadmill by scrapping the old sysocmgr.exe and its INF file. Now there are way more features to pick from than IIS 6.0 but NNTP is dropped and the SMTP is now separated from IIS and is now listed as a *feature* in Windows 2008's Server Manager.

Other changes are explained here:
http://blogs.technet.com/mscom/archive/2007/09/07/the-tasty-morsels-found-in-dogfood-mscom-ops-top-10-changes-in-iis7-0.aspx

In either method, you can no longer specify where the files are to be installed at the onset. This is confirmed with the existence of a batch file to move ISS to another drive written by an IIS team member! Another thing that could be done is to format a new partition and instead of assigning it a drive letter, use the "mount in the following empty NTFS folder" option in disk management to host C:\inetpub before the install. With the lack of ability to specify where to install ANY Service or Feature with the any of the 3 methods, it's as if MS is hinting that UNIX's way of partitions instead of drive letters is the way to go!

All 3 methods share the same key words for installing Roles, Role Services and Features. The following methods work "as-is" on Server 2008 R1 except for PowerShell method which is Server 2008 R2 only. The names of the Roles, Role Services and Features have slightly changed from R1 to R2.

**************
The Pkgmgr.exe method is the simplest but you cannot install SMTP.
It is explained here http://learn.iis.net/page.aspx/133/using-unattend-setup-to-install-iis-7/
And http://learn.iis.net/page.aspx/132/install-iis-7-from-the-command-line/
NOTE: It's very important that the Windows build version within the xml file (version="6.0.6001.16659") is the full version number of the OS, otherwise the xml file won't work.

You can use the following to install ALL of IIS' 7.0 features:
-Create unattend.xml from:

<?xml version="1.0" ?>
<!-- http://learn.iis.net/page.aspx/133/using-unattend-setup-to-install-iis-7/ -->
<unattend xmlns="urn:schemas-microsoft-com:unattend"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<servicing>
<!-- Install a selectable update in a package that is in the Windows Foundation namespace -->
<package action="configure">
<assemblyIdentity
name="Microsoft-Windows-Foundation-Package"
version="6.0.5308.6"
language="neutral"
processorArchitecture="x86"
publicKeyToken="31bf3856ad364e35"
versionScope="nonSxS"
/>
<selection name="IIS-WebServerRole" state="true"/>
<selection name="IIS-WebServer" state="true"/>
<selection name="IIS-CommonHttpFeatures" state="true"/>
<selection name="IIS-StaticContent" state="true"/>
<selection name="IIS-DefaultDocument" state="true"/>
<selection name="IIS-DirectoryBrowsing" state="true"/>
<selection name="IIS-HttpErrors" state="true"/>
<selection name="IIS-HttpRedirect" state="true"/>
<selection name="IIS-ApplicationDevelopment" state="true"/>
<selection name="IIS-ASPNET" state="true"/>
<selection name="IIS-NetFxExtensibility" state="true"/>
<selection name="IIS-ASP" state="true"/>
<selection name="IIS-CGI" state="true"/>
<selection name="IIS-ISAPIExtensions" state="true"/>
<selection name="IIS-ISAPIFilter" state="true"/>
<selection name="IIS-ServerSideIncludes" state="true"/>
<selection name="IIS-HealthAndDiagnostics" state="true"/>
<selection name="IIS-HttpLogging" state="true"/>
<selection name="IIS-LoggingLibraries" state="true"/>
<selection name="IIS-RequestMonitor" state="true"/>
<selection name="IIS-HttpTracing" state="true"/>
<selection name="IIS-CustomLogging" state="true"/>
<selection name="IIS-ODBCLogging" state="true"/>
<selection name="IIS-Security" state="true"/>
<selection name="IIS-BasicAuthentication" state="true"/>
<selection name="IIS-WindowsAuthentication" state="true"/>
<selection name="IIS-DigestAuthentication" state="true"/>
<selection name="IIS-ClientCertificateMappingAuthentication" state="true"/>
<selection name="IIS-IISCertificateMappingAuthentication" state="true"/>
<selection name="IIS-URLAuthorization" state="true"/>
<selection name="IIS-RequestFiltering" state="true"/>
<selection name="IIS-IPSecurity" state="true"/>
<selection name="IIS-Performance" state="true"/>
<selection name="IIS-HttpCompressionStatic" state="true"/>
<selection name="IIS-HttpCompressionDynamic" state="true"/>
<selection name="IIS-WebServerManagementTools" state="true"/>
<selection name="IIS-ManagementConsole" state="true"/>
<selection name="IIS-ManagementScriptingTools" state="true"/>
<selection name="IIS-ManagementService" state="true"/>
<selection name="IIS-IIS6ManagementCompatibility" state="true"/>
<selection name="IIS-Metabase" state="true"/>
<selection name="IIS-WMICompatibility" state="true"/>
<selection name="IIS-LegacyScripts" state="true"/>
<selection name="IIS-LegacySnapIn" state="true"/>
<selection name="IIS-FTPPublishingService" state="true"/>
<selection name="IIS-FTPServer" state="true"/>
<selection name="IIS-FTPManagement" state="true"/>
<selection name="WAS-WindowsActivationService" state="true"/>
<selection name="WAS-ProcessModel" state="true"/>
<selection name="WAS-NetFxEnvironment" state="true"/>
<selection name="WAS-ConfigurationAPI" state="true"/>
</package>
</servicing>
</unattend>

And then launch with: start /w pkgmgr /n:unattend.xml


You can also skip the XML file creation with this one liner:
start /w pkgmgr /l:log.etw /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-Security;IIS-ClientCertificateMappingAuthentication;IIS-IISCertificateMappingAuthentication;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

Now this will install IIS but ONLY on the %SystemDrive% ( C:\ drive).
See the batch file in the next section on how to move it to another drive letter.

******************
The Servermanagercmd.exe will not work in a workstation OS (Vista or Seven) but will be able to install SMTP and any other Features/server Roles you wish at the same time as IIS 7.0. The catch is that MS has deprecated (aka "to be phased out later") in Windows server 2008 R2.

Syntax is as follows:
ServerManagerCmd.exe -query [<query.xml>] [-logPath <log.txt>]
ServerManagerCmd.exe -inputPath <answer.xml> [-resultPath <result.xml> [-restart] | -whatIf] [-logPath <log.txt>]
ServerManagerCmd.exe -install <command-Id> [-setting <setting-name>=<setting value>][-allSubFeatures] [-resultPath <result.xml> [-restart] | -whatIf] [-logPath <log.txt>]
ServerManagerCmd.exe -remove <command-Id> [-resultPath <result.xml> [-restart] | -whatIf] [-logPath <log.txt>]
ServerManagerCmd.exe [-help | -?]

Every time you launch it or its GUI counterpart it updates a log in: C:\windows\LOGS\ServerManager.log

The hardest thing to figure out is the difference between a Role, Role Services and Features.
A Role is a grouping of Role Services. Features are basically Services that have not been grouped under a Role. Role Services can also be part of other Roles. If you specify to install a Role (e.g. Web-Server for IIS 7), its default Role Services will be installed. You can get a full list here: http://technet.microsoft.com/en-us/library/cc875805(WS.10).aspx (Well, at least it was here Aug 28, 2009) but notice they don't tell you which is the "Role" and which is the "Role Service". Since it’s Trial and Error, use the -whatif parameter. You can also get a hint as what is a Role Service by running: ServerManagerCmd.exe -query

Notice that Sub-Roles also exists (e.g. Web-App-Development)

This will install IIS 7.0 (aka the Web-Server "role") without SMTP:
ServerManagerCmd.exe -install Web-Server -allSubFeatures -resultPath C:\TEMP\WebServer.xml -restart

To install IIS 7.0 with default "role services" plus the SMTP "Feature", create IIS7_w_SMTP.xml with the following:
<ServerManagerConfiguration Action="Install" xmlns="http://schemas.microsoft.com/sdm/Windows/ServerManager/Configuration/2007/1">
<Role Id="Web-Server"/>
<Feature Id="SMTP-Server"/>
</ServerManagerConfiguration>

Then launch:
ServerManagerCmd.exe -inputPath .\IIS7_w_SMTP.xml -resultPath .\IIS7_Log_file.xml

Other things to remember:
-If you want to install IIS with your selection of Role Services, don't mention the Web-Server Role or Sub-Roles, just the "Role Services" themselves.
-You cannot have comments in the xml file (e.g. - <!-- ====== --> ) in R1. They are, however, allowed in R2. (Go figure!)


To install IIS 7.0 with ALL "Role Services" plus the SMTP "Feature", create IIS7_w_SMTP.xml with the following:
<ServerManagerConfiguration Action="Install" xmlns="http://schemas.microsoft.com/sdm/Windows/ServerManager/Configuration/2007/1">
<RoleService Id="Web-WebServer"/>
<RoleService Id="Web-Common-Http"/>
<RoleService Id="Web-Static-Content"/>
<RoleService Id="Web-Default-Doc"/>
<RoleService Id="Web-Dir-Browsing"/>
<RoleService Id="Web-Http-Errors"/>
<RoleService Id="Web-Http-Redirect"/>
<RoleService Id="Web-Asp-Net"/>
<RoleService Id="Web-Net-Ext"/>
<RoleService Id="Web-ASP"/>
<RoleService Id="Web-CGI"/>
<RoleService Id="Web-ISAPI-Ext"/>
<RoleService Id="Web-ISAPI-Filter"/>
<RoleService Id="Web-Includes"/>
<RoleService Id="Web-Health"/>
<RoleService Id="Web-Http-Logging"/>
<RoleService Id="Web-Log-Libraries"/>
<RoleService Id="Web-Request-Monitor"/>
<RoleService Id="Web-Http-Tracing"/>
<RoleService Id="Web-Custom-Logging"/>
<RoleService Id="Web-ODBC-Logging"/>
<RoleService Id="Web-Security"/>
<RoleService Id="Web-Basic-Auth"/>
<RoleService Id="Web-Windows-Auth"/>
<RoleService Id="Web-Digest-Auth"/>
<RoleService Id="Web-Client-Auth"/>
<RoleService Id="Web-Cert-Auth"/>
<RoleService Id="Web-Url-Auth"/>
<RoleService Id="Web-Filtering"/>
<RoleService Id="Web-IP-Security"/>
<RoleService Id="Web-Performance"/>
<RoleService Id="Web-Stat-Compression"/>
<RoleService Id="Web-Dyn-Compression"/>
<RoleService Id="Web-Mgmt-Tools"/>
<RoleService Id="Web-Mgmt-Console"/>
<RoleService Id="Web-Scripting-Tools"/>
<RoleService Id="Web-Mgmt-Service"/>
<RoleService Id="Web-Mgmt-Compat"/>
<RoleService Id="Web-Metabase"/>
<RoleService Id="Web-WMI"/>
<RoleService Id="Web-Lgcy-Scripting"/>
<RoleService Id="Web-Lgcy-Mgmt-Console"/>
<RoleService Id="Web-Ftp-Publishing"/>
<RoleService Id="Web-Ftp-Server"/>
<RoleService Id="Web-Ftp-Mgmt-Console"/>
<Feature Id="SMTP-Server"/>
</ServerManagerConfiguration>


Now this will install IIS but ONLY on the %SystemDrive% ( C:\ drive).
http://blogs.iis.net/thomad/archive/2008/02/10/moving-the-iis7-inetpub-directory-to-a-different-drive.aspx
Here, Thomas Deml, an ISS team member shares a script to move the IIS INETPUB folder *after* it is installed. What follows is that script (with a bug fix) since MS' web sites are made of vapour and disappears on a whim:

<< Start of moveiis7root.bat >>
@echo off
IF "%1" == "" goto err
setlocal
set MOVETO=%1:\

REM simple error handling if drive does not exist or argument is wrong
IF NOT EXIST %MOVETO% goto err

REM Backup IIS config before we start changing config to point to the new path
%windir%\system32\inetsrv\appcmd add backup beforeRootMove


REM Stop all IIS services
iisreset /stop

REM Copy all content
REM /O - copy ACLs
REM /E - copy sub directories including empty ones
REM /I - assume destination is a directory
REM /Q - quiet

REM echo on, because user will be prompted if content already exists.
echo on
xcopy %systemdrive%\inetpub %MOVETO%inetpub /O /E /I /Q
@echo off
REM Move AppPool isolation directory
reg add HKLM\System\CurrentControlSet\Services\WAS\Parameters /v ConfigIsolationPath /t REG_SZ /d %MOVETO%inetpub\temp\appPools /f

REM Move logfile directories
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.traceFailedRequestsLogging.directory:"%MOVETO%inetpub\logs\FailedReqLogFiles"
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.logfile.directory:"%MOVETO%inetpub\logs\logfiles"
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralBinaryLogFile.directory:"%MOVETO%inetpub\logs\logfiles"
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralW3CLogFile.directory:"%MOVETO%inetpub\logs\logfiles"

REM Move config history location, temporary files, the path for the Default Web Site and the custom error locations
%windir%\system32\inetsrv\appcmd set config -section:system.applicationhost/configHistory -path:%MOVETO%inetpub\history
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/asp -cache.disktemplateCacheDirectory:"%MOVETO%inetpub\temp\ASP Compiled Templates"
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/httpCompression -directory:"%MOVETO%inetpub\temp\IIS Temporary Compressed Files"
%windir%\system32\inetsrv\appcmd set vdir "Default Web Site/" -physicalPath:%MOVETO%inetpub\wwwroot
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='401'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='403'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='404'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='405'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='406'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='412'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='500'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='501'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='502'].prefixLanguageFilePath:%MOVETO%inetpub\custerr

REM Make sure Service Pack and Hotfix Installers know where the IIS root directories are
reg add HKLM\Software\Microsoft\inetstp /v PathWWWRoot /t REG_SZ /d %moveto%inetpub\wwwroot /f
reg add HKLM\Software\Microsoft\inetstp /v PathFTPRoot /t REG_SZ /d %moveto%inetpub\ftproot /f

REM Restart all IIS services
iisreset /start
echo.
echo.
echo ===============================================================================
echo Moved IIS7 root directory from %systemdrive%\ to %MOVETO%.
echo.
echo Please verify if the move worked. If so you can delete the %systemdrive%\inetpub directory.
echo If something went wrong you can restore the old settings via
echo "APPCMD restore backup beforeRootMove"
echo and
echo "REG delete HKLM\System\CurrentControlSet\Services\WAS\Parameters\ConfigIsolationPath"
echo You also have to reset the PathWWWRoot and PathFTPRoot registry values
echo in HKEY_LOCAL_MACHINE\Software\Microsoft\InetStp.
echo ===============================================================================
echo.
echo.
endlocal
goto success

REM error message if no argument or drive does not exist
:err
echo.
echo New root drive letter required.
echo Here an example how to move the IIS root to the F:\ drive:
echo.
echo MOVEIISROOT.BAT F
echo.
echo.

:success
<< End of moveiis7root.bat >>

AppCMD.exe can be used to tweak some more after the install is completed but I digress.
http://blogs.iis.net/webdevelopertips/archive/2009/01/11/tip-42-did-you-know-configurationeditor-allows-you-to-generate-c-javascript-or-appcmd-script-to-update-configuration.aspx


**************
If you have the RTM version of Windows Server 2008 R2 then you can also use PowerShell.
To launch PowerShell 2.0 from the command-line type: POWERSHELL
* Import the Server Manager Module with: Import-Module ServerManager
* You will get the following cmdlets to list/add/remove features and roles:
Get-WindowsFeature --> lists available/Installed features and roles
Add-WindowsFeature --> installs a feature or role
Remove-WindowsFeature --> removes a feature or role
The rest is poorly documented right now but it seems to borrow heavily from the 2 previous methods.

http://technet.microsoft.com/en-us/library/cc732757.aspx

At this time, there is no PowerShell script to install IIS 7.0 so here is the one I wrote:

# Installs IIS 7.0 with ALL Role-Services Plus SMTP feature
# Creates a log file in the same folder as this script
# CAVEAT: This *ONLY* works on Windows server 2008 R2 (and later?)
#
#
# To Run this Powershell script
# Step 1: Allow Powershell scripts to run
# Start -> Run
# Type: PowerShell <Press Enter>
# Type: Set-ExecutionPolicy Unrestricted <Press Enter>
# Type: <Press Enter>
#
# Step 2: Run this Powershell Script
# From the PowerShell Prompt
# Browse to the folder where this Powershell Script is located
# Type: . <name of this Script>
# OR
#
# Right-click on the Powershell Script file (*.ps1)
# Select "Run with PowerShell"
#
# Powershell Tip: Do not point Add-WindowsFeature's -logPath and redirection (>> $LogFile) to the same file
# Powershell gets confused as to what encoding to use (ANSI/UTF-8) and you will get Chinese characters!?!
# Use "transcript" instead as done below.
# NOTE: for some reasons it talks about "activities not shown..."
#

#Make $LogFile match the Powershell script name with a date and time stamp followed by ".log"
$dt = Get-Date -format "yyyyMMdd_hhmm"
$LogFile = ($MyInvocation.MyCommand.Name).Replace(".ps1","_$dt.log")


start-transcript $LogFile #start the transcript (aka Logging)
trap { stop-transcript; break} #error trapping code to stop the transcript and break out of script
#(alternatively could use "continue" execution)


# Load ServerManager Powershell module
Import-Module ServerManager

Add-WindowsFeature -Name Web-WebServer
Add-WindowsFeature -Name Web-Common-Http
Add-WindowsFeature -Name Web-Static-Content
Add-WindowsFeature -Name Web-Default-Doc
Add-WindowsFeature -Name Web-Dir-Browsing
Add-WindowsFeature -Name Web-Http-Errors
Add-WindowsFeature -Name Web-Http-Redirect
Add-WindowsFeature -Name Web-DAV-Publishing
Add-WindowsFeature -Name Web-Asp-Net
Add-WindowsFeature -Name Web-Net-Ext
Add-WindowsFeature -Name Web-ASP
Add-WindowsFeature -Name Web-CGI
Add-WindowsFeature -Name Web-ISAPI-Ext
Add-WindowsFeature -Name Web-ISAPI-Filter
Add-WindowsFeature -Name Web-Includes
Add-WindowsFeature -Name Web-Health
Add-WindowsFeature -Name Web-Http-Logging
Add-WindowsFeature -Name Web-Log-Libraries
Add-WindowsFeature -Name Web-Request-Monitor
Add-WindowsFeature -Name Web-Http-Tracing
Add-WindowsFeature -Name Web-Custom-Logging
Add-WindowsFeature -Name Web-ODBC-Logging
Add-WindowsFeature -Name Web-Security
Add-WindowsFeature -Name Web-Basic-Auth
Add-WindowsFeature -Name Web-Windows-Auth
Add-WindowsFeature -Name Web-Digest-Auth
Add-WindowsFeature -Name Web-Client-Auth
Add-WindowsFeature -Name Web-Cert-Auth
Add-WindowsFeature -Name Web-Url-Auth
Add-WindowsFeature -Name Web-Filtering
Add-WindowsFeature -Name Web-IP-Security
Add-WindowsFeature -Name Web-Performance
Add-WindowsFeature -Name Web-Stat-Compression
Add-WindowsFeature -Name Web-Dyn-Compression
Add-WindowsFeature -Name Web-Mgmt-Tools
Add-WindowsFeature -Name Web-Mgmt-Console
Add-WindowsFeature -Name Web-Scripting-Tools
Add-WindowsFeature -Name Web-Mgmt-Service
Add-WindowsFeature -Name Web-Mgmt-Compat
Add-WindowsFeature -Name Web-Metabase
Add-WindowsFeature -Name Web-WMI
Add-WindowsFeature -Name Web-Lgcy-Scripting
Add-WindowsFeature -Name Web-Lgcy-Mgmt-Console
Add-WindowsFeature -Name Web-Ftp-Server
Add-WindowsFeature -Name Web-WHC

Add-WindowsFeature -Name SMTP-Server

stop-transcript #stop the transcript (aka Logging)

#pause 50 Seconds (There is no "PAUSE" in PS, thx MS!)
Start-sleep -s 50


You are still able to use AppCMD.exe to tweak after install (e.g. the batch file to move c:\ inetpub) but it is rumoured that it will also be assimilated into a PowerSmell module.
Setup Information:
Setup Type: unspecified
Deployment Method Used: unspecified
Deployment Difficulty: unspecified
Platform(s): Windows
Please log in to comment
5
Note
IIS 7.0 can be installed unattended using one of 3 methods:
-Pkgmgr.exe (Works in Vista, Server 2008, and Server 2008 R2)
-Servermanagercmd.exe (Server 2008 and deprecated in Server 2008 R2) (not available in Vista or Seven)
-ServerManager PowerShell cmdlets (Server 2008 R2 ONLY!!)

In true MS form, MS has turned on the upgrade threadmill by scrapping the old sysocmgr.exe and its INF file. Now there are way more features to pick from than IIS 6.0 but NNTP is dropped and the SMTP is now separated from IIS and is now listed as a *feature* in Windows 2008's Server Manager.

Other changes are explained here:
http://blogs.technet.com/mscom/archive/2007/09/07/the-tasty-morsels-found-in-dogfood-mscom-ops-top-10-changes-in-iis7-0.aspx

In either method, you can no longer specify where the files are to be installed at the onset. This is confirmed with the existence of a batch file to move ISS to another drive written by an IIS team member! Another thing that could be done is to format a new partition and instead of assigning it a drive letter, use the "mount in the following empty NTFS folder" option in disk management to host C:\inetpub before the install. With the lack of ability to specify where to install ANY Service or Feature with the any of the 3 methods, it's as if MS is hinting that UNIX's way of partitions instead of drive letters is the way to go!

All 3 methods share the same key words for installing Roles, Role Services and Features. The following methods work "as-is" on Server 2008 R1 except for PowerShell method which is Server 2008 R2 only. The names of the Roles, Role Services and Features have slightly changed from R1 to R2.

**************
The Pkgmgr.exe method is the simplest but you cannot install SMTP.
It is explained here http://learn.iis.net/page.aspx/133/using-unattend-setup-to-install-iis-7/
And http://learn.iis.net/page.aspx/132/install-iis-7-from-the-command-line/
NOTE: It's very important that the Windows build version within the xml file (version="6.0.6001.16659") is the full version number of the OS, otherwise the xml file won't work.

You can use the following to install ALL of IIS' 7.0 features:
-Create unattend.xml from:

<?xml version="1.0" ?>
<!-- http://learn.iis.net/page.aspx/133/using-unattend-setup-to-install-iis-7/ -->
<unattend xmlns="urn:schemas-microsoft-com:unattend"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<servicing>
<!-- Install a selectable update in a package that is in the Windows Foundation namespace -->
<package action="configure">
<assemblyIdentity
name="Microsoft-Windows-Foundation-Package"
version="6.0.5308.6"
language="neutral"
processorArchitecture="x86"
publicKeyToken="31bf3856ad364e35"
versionScope="nonSxS"
/>
<selection name="IIS-WebServerRole" state="true"/>
<selection name="IIS-WebServer" state="true"/>
<selection name="IIS-CommonHttpFeatures" state="true"/>
<selection name="IIS-StaticContent" state="true"/>
<selection name="IIS-DefaultDocument" state="true"/>
<selection name="IIS-DirectoryBrowsing" state="true"/>
<selection name="IIS-HttpErrors" state="true"/>
<selection name="IIS-HttpRedirect" state="true"/>
<selection name="IIS-ApplicationDevelopment" state="true"/>
<selection name="IIS-ASPNET" state="true"/>
<selection name="IIS-NetFxExtensibility" state="true"/>
<selection name="IIS-ASP" state="true"/>
<selection name="IIS-CGI" state="true"/>
<selection name="IIS-ISAPIExtensions" state="true"/>
<selection name="IIS-ISAPIFilter" state="true"/>
<selection name="IIS-ServerSideIncludes" state="true"/>
<selection name="IIS-HealthAndDiagnostics" state="true"/>
<selection name="IIS-HttpLogging" state="true"/>
<selection name="IIS-LoggingLibraries" state="true"/>
<selection name="IIS-RequestMonitor" state="true"/>
<selection name="IIS-HttpTracing" state="true"/>
<selection name="IIS-CustomLogging" state="true"/>
<selection name="IIS-ODBCLogging" state="true"/>
<selection name="IIS-Security" state="true"/>
<selection name="IIS-BasicAuthentication" state="true"/>
<selection name="IIS-WindowsAuthentication" state="true"/>
<selection name="IIS-DigestAuthentication" state="true"/>
<selection name="IIS-ClientCertificateMappingAuthentication" state="true"/>
<selection name="IIS-IISCertificateMappingAuthentication" state="true"/>
<selection name="IIS-URLAuthorization" state="true"/>
<selection name="IIS-RequestFiltering" state="true"/>
<selection name="IIS-IPSecurity" state="true"/>
<selection name="IIS-Performance" state="true"/>
<selection name="IIS-HttpCompressionStatic" state="true"/>
<selection name="IIS-HttpCompressionDynamic" state="true"/>
<selection name="IIS-WebServerManagementTools" state="true"/>
<selection name="IIS-ManagementConsole" state="true"/>
<selection name="IIS-ManagementScriptingTools" state="true"/>
<selection name="IIS-ManagementService" state="true"/>
<selection name="IIS-IIS6ManagementCompatibility" state="true"/>
<selection name="IIS-Metabase" state="true"/>
<selection name="IIS-WMICompatibility" state="true"/>
<selection name="IIS-LegacyScripts" state="true"/>
<selection name="IIS-LegacySnapIn" state="true"/>
<selection name="IIS-FTPPublishingService" state="true"/>
<selection name="IIS-FTPServer" state="true"/>
<selection name="IIS-FTPManagement" state="true"/>
<selection name="WAS-WindowsActivationService" state="true"/>
<selection name="WAS-ProcessModel" state="true"/>
<selection name="WAS-NetFxEnvironment" state="true"/>
<selection name="WAS-ConfigurationAPI" state="true"/>
</package>
</servicing>
</unattend>

And then launch with: start /w pkgmgr /n:unattend.xml


You can also skip the XML file creation with this one liner:
start /w pkgmgr /l:log.etw /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-Security;IIS-ClientCertificateMappingAuthentication;IIS-IISCertificateMappingAuthentication;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

Now this will install IIS but ONLY on the %SystemDrive% ( C:\ drive).
See the batch file in the next section on how to move it to another drive letter.

******************
The Servermanagercmd.exe will not work in a workstation OS (Vista or Seven) but will be able to install SMTP and any other Features/server Roles you wish at the same time as IIS 7.0. The catch is that MS has deprecated (aka "to be phased out later") in Windows server 2008 R2.

Syntax is as follows:
ServerManagerCmd.exe -query [<query.xml>] [-logPath <log.txt>]
ServerManagerCmd.exe -inputPath <answer.xml> [-resultPath <result.xml> [-restart] | -whatIf] [-logPath <log.txt>]
ServerManagerCmd.exe -install <command-Id> [-setting <setting-name>=<setting value>][-allSubFeatures] [-resultPath <result.xml> [-restart] | -whatIf] [-logPath <log.txt>]
ServerManagerCmd.exe -remove <command-Id> [-resultPath <result.xml> [-restart] | -whatIf] [-logPath <log.txt>]
ServerManagerCmd.exe [-help | -?]

Every time you launch it or its GUI counterpart it updates a log in: C:\windows\LOGS\ServerManager.log

The hardest thing to figure out is the difference between a Role, Role Services and Features.
A Role is a grouping of Role Services. Features are basically Services that have not been grouped under a Role. Role Services can also be part of other Roles. If you specify to install a Role (e.g. Web-Server for IIS 7), its default Role Services will be installed. You can get a full list here: http://technet.microsoft.com/en-us/library/cc875805(WS.10).aspx (Well, at least it was here Aug 28, 2009) but notice they don't tell you which is the "Role" and which is the "Role Service". Since it’s Trial and Error, use the -whatif parameter. You can also get a hint as what is a Role Service by running: ServerManagerCmd.exe -query

Notice that Sub-Roles also exists (e.g. Web-App-Development)

This will install IIS 7.0 (aka the Web-Server "role") without SMTP:
ServerManagerCmd.exe -install Web-Server -allSubFeatures -resultPath C:\TEMP\WebServer.xml -restart

To install IIS 7.0 with default "role services" plus the SMTP "Feature", create IIS7_w_SMTP.xml with the following:
<ServerManagerConfiguration Action="Install" xmlns="http://schemas.microsoft.com/sdm/Windows/ServerManager/Configuration/2007/1">
<Role Id="Web-Server"/>
<Feature Id="SMTP-Server"/>
</ServerManagerConfiguration>

Then launch:
ServerManagerCmd.exe -inputPath .\IIS7_w_SMTP.xml -resultPath .\IIS7_Log_file.xml

Other things to remember:
-If you want to install IIS with your selection of Role Services, don't mention the Web-Server Role or Sub-Roles, just the "Role Services" themselves.
-You cannot have comments in the xml file (e.g. - <!-- ====== --> ) in R1. They are, however, allowed in R2. (Go figure!)


To install IIS 7.0 with ALL "Role Services" plus the SMTP "Feature", create IIS7_w_SMTP.xml with the following:
<ServerManagerConfiguration Action="Install" xmlns="http://schemas.microsoft.com/sdm/Windows/ServerManager/Configuration/2007/1">
<RoleService Id="Web-WebServer"/>
<RoleService Id="Web-Common-Http"/>
<RoleService Id="Web-Static-Content"/>
<RoleService Id="Web-Default-Doc"/>
<RoleService Id="Web-Dir-Browsing"/>
<RoleService Id="Web-Http-Errors"/>
<RoleService Id="Web-Http-Redirect"/>
<RoleService Id="Web-Asp-Net"/>
<RoleService Id="Web-Net-Ext"/>
<RoleService Id="Web-ASP"/>
<RoleService Id="Web-CGI"/>
<RoleService Id="Web-ISAPI-Ext"/>
<RoleService Id="Web-ISAPI-Filter"/>
<RoleService Id="Web-Includes"/>
<RoleService Id="Web-Health"/>
<RoleService Id="Web-Http-Logging"/>
<RoleService Id="Web-Log-Libraries"/>
<RoleService Id="Web-Request-Monitor"/>
<RoleService Id="Web-Http-Tracing"/>
<RoleService Id="Web-Custom-Logging"/>
<RoleService Id="Web-ODBC-Logging"/>
<RoleService Id="Web-Security"/>
<RoleService Id="Web-Basic-Auth"/>
<RoleService Id="Web-Windows-Auth"/>
<RoleService Id="Web-Digest-Auth"/>
<RoleService Id="Web-Client-Auth"/>
<RoleService Id="Web-Cert-Auth"/>
<RoleService Id="Web-Url-Auth"/>
<RoleService Id="Web-Filtering"/>
<RoleService Id="Web-IP-Security"/>
<RoleService Id="Web-Performance"/>
<RoleService Id="Web-Stat-Compression"/>
<RoleService Id="Web-Dyn-Compression"/>
<RoleService Id="Web-Mgmt-Tools"/>
<RoleService Id="Web-Mgmt-Console"/>
<RoleService Id="Web-Scripting-Tools"/>
<RoleService Id="Web-Mgmt-Service"/>
<RoleService Id="Web-Mgmt-Compat"/>
<RoleService Id="Web-Metabase"/>
<RoleService Id="Web-WMI"/>
<RoleService Id="Web-Lgcy-Scripting"/>
<RoleService Id="Web-Lgcy-Mgmt-Console"/>
<RoleService Id="Web-Ftp-Publishing"/>
<RoleService Id="Web-Ftp-Server"/>
<RoleService Id="Web-Ftp-Mgmt-Console"/>
<Feature Id="SMTP-Server"/>
</ServerManagerConfiguration>


Now this will install IIS but ONLY on the %SystemDrive% ( C:\ drive).
http://blogs.iis.net/thomad/archive/2008/02/10/moving-the-iis7-inetpub-directory-to-a-different-drive.aspx
Here, Thomas Deml, an ISS team member shares a script to move the IIS INETPUB folder *after* it is installed. What follows is that script (with a bug fix) since MS' web sites are made of vapour and disappears on a whim:

<< Start of moveiis7root.bat >>
@echo off
IF "%1" == "" goto err
setlocal
set MOVETO=%1:\

REM simple error handling if drive does not exist or argument is wrong
IF NOT EXIST %MOVETO% goto err

REM Backup IIS config before we start changing config to point to the new path
%windir%\system32\inetsrv\appcmd add backup beforeRootMove


REM Stop all IIS services
iisreset /stop

REM Copy all content
REM /O - copy ACLs
REM /E - copy sub directories including empty ones
REM /I - assume destination is a directory
REM /Q - quiet

REM echo on, because user will be prompted if content already exists.
echo on
xcopy %systemdrive%\inetpub %MOVETO%inetpub /O /E /I /Q
@echo off
REM Move AppPool isolation directory
reg add HKLM\System\CurrentControlSet\Services\WAS\Parameters /v ConfigIsolationPath /t REG_SZ /d %MOVETO%inetpub\temp\appPools /f

REM Move logfile directories
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.traceFailedRequestsLogging.directory:"%MOVETO%inetpub\logs\FailedReqLogFiles"
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.logfile.directory:"%MOVETO%inetpub\logs\logfiles"
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralBinaryLogFile.directory:"%MOVETO%inetpub\logs\logfiles"
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralW3CLogFile.directory:"%MOVETO%inetpub\logs\logfiles"

REM Move config history location, temporary files, the path for the Default Web Site and the custom error locations
%windir%\system32\inetsrv\appcmd set config -section:system.applicationhost/configHistory -path:%MOVETO%inetpub\history
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/asp -cache.disktemplateCacheDirectory:"%MOVETO%inetpub\temp\ASP Compiled Templates"
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/httpCompression -directory:"%MOVETO%inetpub\temp\IIS Temporary Compressed Files"
%windir%\system32\inetsrv\appcmd set vdir "Default Web Site/" -physicalPath:%MOVETO%inetpub\wwwroot
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='401'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='403'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='404'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='405'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='406'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='412'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='500'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='501'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
%windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='502'].prefixLanguageFilePath:%MOVETO%inetpub\custerr

REM Make sure Service Pack and Hotfix Installers know where the IIS root directories are
reg add HKLM\Software\Microsoft\inetstp /v PathWWWRoot /t REG_SZ /d %moveto%inetpub\wwwroot /f
reg add HKLM\Software\Microsoft\inetstp /v PathFTPRoot /t REG_SZ /d %moveto%inetpub\ftproot /f

REM Restart all IIS services
iisreset /start
echo.
echo.
echo ===============================================================================
echo Moved IIS7 root directory from %systemdrive%\ to %MOVETO%.
echo.
echo Please verify if the move worked. If so you can delete the %systemdrive%\inetpub directory.
echo If something went wrong you can restore the old settings via
echo "APPCMD restore backup beforeRootMove"
echo and
echo "REG delete HKLM\System\CurrentControlSet\Services\WAS\Parameters\ConfigIsolationPath"
echo You also have to reset the PathWWWRoot and PathFTPRoot registry values
echo in HKEY_LOCAL_MACHINE\Software\Microsoft\InetStp.
echo ===============================================================================
echo.
echo.
endlocal
goto success

REM error message if no argument or drive does not exist
:err
echo.
echo New root drive letter required.
echo Here an example how to move the IIS root to the F:\ drive:
echo.
echo MOVEIISROOT.BAT F
echo.
echo.

:success
<< End of moveiis7root.bat >>

AppCMD.exe can be used to tweak some more after the install is completed but I digress.
http://blogs.iis.net/webdevelopertips/archive/2009/01/11/tip-42-did-you-know-configurationeditor-allows-you-to-generate-c-javascript-or-appcmd-script-to-update-configuration.aspx


**************
If you have the RTM version of Windows Server 2008 R2 then you can also use PowerShell.
To launch PowerShell 2.0 from the command-line type: POWERSHELL
* Import the Server Manager Module with: Import-Module ServerManager
* You will get the following cmdlets to list/add/remove features and roles:
Get-WindowsFeature --> lists available/Installed features and roles
Add-WindowsFeature --> installs a feature or role
Remove-WindowsFeature --> removes a feature or role
The rest is poorly documented right now but it seems to borrow heavily from the 2 previous methods.

http://technet.microsoft.com/en-us/library/cc732757.aspx

At this time, there is no PowerShell script to install IIS 7.0 so here is the one I wrote:

# Installs IIS 7.0 with ALL Role-Services Plus SMTP feature
# Creates a log file in the same folder as this script
# CAVEAT: This *ONLY* works on Windows server 2008 R2 (and later?)
#
#
# To Run this Powershell script
# Step 1: Allow Powershell scripts to run
# Start -> Run
# Type: PowerShell <Press Enter>
# Type: Set-ExecutionPolicy Unrestricted <Press Enter>
# Type: <Press Enter>
#
# Step 2: Run this Powershell Script
# From the PowerShell Prompt
# Browse to the folder where this Powershell Script is located
# Type: . <name of this Script>
# OR
#
# Right-click on the Powershell Script file (*.ps1)
# Select "Run with PowerShell"
#
# Powershell Tip: Do not point Add-WindowsFeature's -logPath and redirection (>> $LogFile) to the same file
# Powershell gets confused as to what encoding to use (ANSI/UTF-8) and you will get Chinese characters!?!
# Use "transcript" instead as done below.
# NOTE: for some reasons it talks about "activities not shown..."
#

#Make $LogFile match the Powershell script name with a date and time stamp followed by ".log"
$dt = Get-Date -format "yyyyMMdd_hhmm"
$LogFile = ($MyInvocation.MyCommand.Name).Replace(".ps1","_$dt.log")


start-transcript $LogFile #start the transcript (aka Logging)
trap { stop-transcript; break} #error trapping code to stop the transcript and break out of script
#(alternatively could use "continue" execution)


# Load ServerManager Powershell module
Import-Module ServerManager

Add-WindowsFeature -Name Web-WebServer
Add-WindowsFeature -Name Web-Common-Http
Add-WindowsFeature -Name Web-Static-Content
Add-WindowsFeature -Name Web-Default-Doc
Add-WindowsFeature -Name Web-Dir-Browsing
Add-WindowsFeature -Name Web-Http-Errors
Add-WindowsFeature -Name Web-Http-Redirect
Add-WindowsFeature -Name Web-DAV-Publishing
Add-WindowsFeature -Name Web-Asp-Net
Add-WindowsFeature -Name Web-Net-Ext
Add-WindowsFeature -Name Web-ASP
Add-WindowsFeature -Name Web-CGI
Add-WindowsFeature -Name Web-ISAPI-Ext
Add-WindowsFeature -Name Web-ISAPI-Filter
Add-WindowsFeature -Name Web-Includes
Add-WindowsFeature -Name Web-Health
Add-WindowsFeature -Name Web-Http-Logging
Add-WindowsFeature -Name Web-Log-Libraries
Add-WindowsFeature -Name Web-Request-Monitor
Add-WindowsFeature -Name Web-Http-Tracing
Add-WindowsFeature -Name Web-Custom-Logging
Add-WindowsFeature -Name Web-ODBC-Logging
Add-WindowsFeature -Name Web-Security
Add-WindowsFeature -Name Web-Basic-Auth
Add-WindowsFeature -Name Web-Windows-Auth
Add-WindowsFeature -Name Web-Digest-Auth
Add-WindowsFeature -Name Web-Client-Auth
Add-WindowsFeature -Name Web-Cert-Auth
Add-WindowsFeature -Name Web-Url-Auth
Add-WindowsFeature -Name Web-Filtering
Add-WindowsFeature -Name Web-IP-Security
Add-WindowsFeature -Name Web-Performance
Add-WindowsFeature -Name Web-Stat-Compression
Add-WindowsFeature -Name Web-Dyn-Compression
Add-WindowsFeature -Name Web-Mgmt-Tools
Add-WindowsFeature -Name Web-Mgmt-Console
Add-WindowsFeature -Name Web-Scripting-Tools
Add-WindowsFeature -Name Web-Mgmt-Service
Add-WindowsFeature -Name Web-Mgmt-Compat
Add-WindowsFeature -Name Web-Metabase
Add-WindowsFeature -Name Web-WMI
Add-WindowsFeature -Name Web-Lgcy-Scripting
Add-WindowsFeature -Name Web-Lgcy-Mgmt-Console
Add-WindowsFeature -Name Web-Ftp-Server
Add-WindowsFeature -Name Web-WHC

Add-WindowsFeature -Name SMTP-Server

stop-transcript #stop the transcript (aka Logging)

#pause 50 Seconds (There is no "PAUSE" in PS, thx MS!)
Start-sleep -s 50


You are still able to use AppCMD.exe to tweak after install (e.g. the batch file to move c:\ inetpub) but it is rumoured that it will also be assimilated into a PowerSmell module.
Setup Information:
Setup Type: unspecified
Deployment Method Used: unspecified
Deployment Difficulty: unspecified
Platform(s): Windows
Please log in to comment
3
Note
The following is the Move_IIS7.bat (moveiis7root.zip) translated to PowerShell.
>>> Use at your own risk. <<<


# REM The following it the CMD created by Thomas Deml, an ISS team member
#http://blogs.iis.net/thomad/archive/2008/02/10/moving-the-iis7-inetpub-directory-to-a-different-drive.aspx
# now translated to Powershell by misterd (Ottawa, Canada)

#Pickup Drive letter from command line

$MOVETO=$arg:
Write-host $MOVETO

#REM simple error handling if drive does not exist or argument is wrong
if (-not (test-path $MOVETO)){
echo $MOVETO + " drive does not exist"
EXIT 2
}

Write-host
Write-host *****************************************
Write-host Moving C:\inetpub\ to ${MOVETO}inetpubWrite-host *****************************************
Write-host



Write-host REM Backup IIS config before we start changing config to point to the new path
& $env:WINDIR\system32\inetsrv\appcmd add backup beforeRootMove


Write-host Stop all IIS services
iisreset /stop

#REM Copy all content
#REM /O - copy ACLs
#REM /E - copy sub directories including empty ones
#REM /I - assume destination is a directory
#REM /Q - quiet

#CAVEAT: the following does not show up in log files

Write-host REM Xcopy $env:systemdrive\inetpub to ${MOVETO}inetpub folder
xcopy $env:systemdrive\inetpub ${MOVETO}inetpub /O /E /I /Q


Write-host REM Move AppPool isolation directory
reg add HKLM\System\CurrentControlSet\Services\WAS\Parameters /v ConfigIsolationPath /t REG_SZ /d "${MOVETO}inetpub\temp\appPools" /f


Write-host REM Move logfile directories
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:system.applicationHost/sites" "-siteDefaults.traceFailedRequestsLogging.directory: ""${MOVETO}inetpub\logs\FailedReqLogFiles"""
& $env:windir\system32\inetsrv\appcmd set config "-section:system.applicationHost/sites" "-siteDefaults.logfile.directory:""${MOVETO}inetpub\logs\FailedReqLogFiles"""
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:system.applicationHost/log" "-centralBinaryLogFile.directory:""${MOVETO}inetpub\logs\logfiles"""
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:system.applicationHost/log" "-centralW3CLogFile.directory:""${MOVETO}inetpub\logs\logfiles"""


Write-host REM Move config history location
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:system.applicationhost/configHistory" "-path:${MOVETO}inetpub\history"


Write-host REM Move temporary files location
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:system.webServer/asp" "-cache.disktemplateCacheDirectory:${MOVETO}inetpub\temp\ASP Compiled Templates"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:system.webServer/httpCompression" "-directory:${MOVETO}inetpub\temp\IIS Temporary Compressed Files"


Write-host REM Move the path for the Default Web Site location
& $env:WINDIR\system32\inetsrv\appcmd set vdir "Default Web Site/" "-physicalPath:${MOVETO}inetpub\wwwroot"


Write-host REM Move the path for the custom error locations
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='401'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='403'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='404'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='405'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='406'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='412'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='500'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='501'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"
& $env:WINDIR\system32\inetsrv\appcmd set config "-section:httpErrors" "/[statusCode='502'].prefixLanguageFilePath:${MOVETO}inetpub\custerr"


Write-host REM Make sure Service Pack and Hotfix Installers know where the IIS root directories are
reg add HKLM\Software\Microsoft\inetstp /v PathWWWRoot /t REG_SZ /d ${MOVETO}inetpub\wwwroot /f
reg add HKLM\Software\Microsoft\inetstp /v PathFTPRoot /t REG_SZ /d ${MOVETO}inetpub\ftproot /f

Write-host REM Restart all IIS services
iisreset /start

Write-host
Write-host ===============================================================================
Write-host Moved IIS7 root directory from $env:{systemdrive}\ to ${MOVETO}\.
Write-host
Write-host Please verify if the move worked. If so you can delete the $env:{systemdrive}\inetpub directory.
Write-host If something went wrong you can restore the old settings via
Write-host "APPCMD restore backup beforeRootMove"
Write-host and
Write-host "REG delete HKLM\System\CurrentControlSet\Services\WAS\Parameters\ConfigIsolationPath"
Write-host You also have to reset the PathWWWRoot and PathFTPRoot registry values
Write-host in HKEY_LOCAL_MACHINE\Software\Microsoft\InetStp.
Write-host ===============================================================================
Write-host

read-host 'Press ENTER key to continue...' # aka Pause
Setup Information:
Setup Type: unspecified
Deployment Method Used: unspecified
Deployment Difficulty: unspecified
Platform(s): Windows
Please log in to comment

Inventory Records (1)

View inventory records anonymously contributed by opt-in users of the K1000 Systems Management Appliance.

Versions

Internet Information Server (IIS)

Version

7

Questions & Answers (1)

Questions & Answers related to Microsoft Internet Information Server (IIS)

2
ANSWERS

Blogs (1)

Blog posts related to Microsoft Internet Information Server (IIS)

Reviews (0)

Reviews related to Microsoft Internet Information Server (IIS)