Mika: Hi, I only just joined and might have missed something :( Is the demo script available somewhere?
Mai-lan: I’ve attached a couple of the appcmd batch files that I showed during our presentation.
Salam: Is IIS 7 going to support sFTP, I saw some SSL icons on FTP
Mai-lan: IIS is shipping a new secure FTP server as a downloadable module from IIS.NET at the end of February. If you download the module to your Windows Server 2008 installation, it will integrate into your existing installation, including the management of the server through IIS7 Manager.
salam: 1st Q, how come you were able to create a 2nd web site on the same port and IP where the default one is running without getting an error?
Mai-lan: You can do this by having two different host headers. Host headers provide for an alias so that they can be differentiated and processed by the right pool. You have one IP address per server and thousands of host-header based web-sites. You can copy and paste the following lines into a batch file or just paste them in an elevated command-line:
REM CREATE SITE 1 DIRECTORY
Md %systemdrive%\inetpub\wwwroot\site1
REM CREATE DEFAULT.HTM IN SITE DIRECTORY
echo 'this is site 1' >> %systemdrive%\inetpub\wwwroot\site1\default.htm
REM ADD SITE1 VIA APPCMD
%windir%\system32\inetsrv\appcmd add site -name:site1 -physicalPath:%systemdrive%\inetpub\wwwroot\site1 -bindings:http/*:80:site1
REM ADD HOST HEADER TO HOSTS FILE SO THAT THE NAME 'SITE1" CAN BE RESOLVED BY DNS
echo 127.0.0.1 site1 >> %windir%\system32\drivers\etc\hosts
REM DO THE SAME FOR SITE 2
Md %systemdrive%\inetpub\wwwroot\site2
echo 'this is site 2' >> %systemdrive%\inetpub\wwwroot\site2\default.htm
%windir%\system32\inetsrv\appcmd add site -name:site2 -physicalPath:%systemdrive%\inetpub\wwwroot\site2 -bindings:http/*:80:site2
echo 127.0.0.1 site2 >> %windir%\system32\drivers\etc\hosts
REM REQUEST SITE1 AND SITE 2 VIA IE
start http://site1
start http://site2
Chris: would you please show again how to load the assembly, and get the iis object?
Mai-lan: Sure. Here it is:
# Load assembly explicitly
$mwaPath = join-path $env:systemroot system32\inetsrv\microsoft.web.administration.dll
$mwa = [System.Reflection.Assembly]::LoadFrom($mwaPath)
# create configuration object
$cfg = new-object Microsoft.Web.Administration.ServerManager
salam: Did you create a virtual directory or a new web site? if it is a VD, then I have no problem, but if it was a new web site, then please explain
Mai-lan: This is a good point. If you create a new site using MWA, you have to create a new virtual directory since that is a required parameter. For example, here’s the syntax: Sites.Add("NewSite", "http", "*:8080:", "d:\\MySite"). Here is a good article about using MWA with examples: http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Using-Microsoft-Web-Administration/How-to-Use-Microsoft-Web-Administration?Page=2. I was using AppCmd in the demo. I was creating a site, but I was NOT actually creating a site that would really work because in the demo I didn’t add the physical path and the bindings. When you create a site using AppCmd, you have to use the syntax of appcmd add site /name:string /id:uint /physicalPath:string /bindings:string to really add a site that works. Note that AppCmd will not throw you an error if you create a site without physical path and bindings. You will create a site (like I did in the demo) but it doesn’t have the required information to be fully functional. I’ll demo it with all parameters next time, I don’t want it to be misleading.
tom: Can you describe what are SCRegEdit.wsf, Netsh/Netdom?
Mai-lan: They are Server Core tools for management (not specific to IIS). SCRegEdit.wsf is included in Server Core to more easily enable automatic updates, enable Terminal Server, Remote Admin Mode, enable remote IPSec Monitor management and configure DNS SRV record weight and priority. Netdom is there to let you join a domain. You can learn more at: http://technet2.microsoft.com/windowsserver/longhorn/en/library/bab0f1a1-54aa-4cef-9164-139e8bcc44751033.mspx?mfr=true. There is also a newsgroup on Server Core: http://forums.microsoft.com/TechNet/ShowForum.aspx?ForumID=582&SiteID=17.
Mika: Thanks for a concise summary on IIS admin automation! I'm looking forward on http://blogs.iis.net/mailant
Arthur: not sure if this is the right forum, but related to automated install, from what I have seen IIS will only install on the C drive with IIS 7 and we cannot point the install to another drive, do you know if there is a reason for that?
Mai-lan: INETPUB goes to C drive and there is no way to override that. Sorry...
chris: Excelent Job! Thank You
Mai-lan: No problem, thanks for coming.
chris: When I try to run appcmd on my server the program is not found. Could it that I need a later version of 2008? (Server Longhorn)Mai-lan: AppCmd is located in the %systemroot%\system32\inetsrv\ directory. Because it is not path of the PATH automatically, you need to use the full path to the executable. Alternatively, you canto simplify all the dir switching, you can add the inetsrv directory to the path on your machine so that you can access AppCmd.exe directly from any location.