Where can I find management scripts for IIS 6.0? - iis

I'm running Windows 2003 R2 and IIS 6.0 with web applications written in ASP.NET.
I am looking for good samples of scripts (.bat, .cmd, .VBS, or powershell) to allow me to:
For websites:
Create website
Verify if website exists
Delete website
For virtual directories:
Create virtual directory
Verify if virtual directory exists
Delete virtual directory
For application pools:
Create application pool
Verify if application pool exists
Delete application pool
Assigning website to application pool
thanks..

I answered a similar question the other day:
Automated creation of IIS websites (Stack Overflow)
You can use the System.DirectoryServices namespace directly from PowerShell as well as C#.

Most of what you need can be found in the system32 directory. Look for the files:
iis*.vbs
for start run:
cscript c:\WINDOWS\system32\iisweb.vbs /?
To create application pool, look at David Wang post.

Related

How can I copy all IIS setting, configurations, application pools from one IIS box to another?

I have an IIS box on windows server 2012 and I want to mirror image the same settings, application pools, web sites and other configurations in another server that is also windows server 2012.
How Can I do that?
Is there any possibility to automate this process as I have to do this process very repetitively?
To Backup and Restore IIS configuration to Another Server you could try below steps:
1)if you configured the certificate with old iis site you need to Backup (export) of IIS certificates.
2)open the command prompt as administrator and create IIS configuration backup on the first server by using below command:
cd c:\Windows\system32\inetsrv
appcmd add backup srviis1-backup-2019
srviis1-backup-2019 this is a backup folder name.
After the command has been executed, a folder with your backup name appears in c:\Windows\system32\inetsrv\backup. Here is its contents for my simple website:
administration.config
applicationHost.config
MBSchema.xml
MetaBase.xml
redirection.config
3)Copy the backup folder to the same directory c:\windows\system32\backup on another server.
To display the list of all available backups, run the following command:
appcmd list backup
4)Recover IIS configuration from this backup:
appcmd restore backup srviis1-backup-2019
The list of restrictions and important issues:
The same IIS version has to be used on both servers
If any application pool is run not from the integrated accounts, they
have to be available on another server as well
Before recovery, you should export and migrate all current
certificates to the new server
I found a really genuine and effective way of migrating IIS(complete web application with all settings). It does not depend on IIS version also.
There is an API web deploy api that we can use to do this. We can do this using command line arguments or an IIS extension is also available for the same that will ease your IIS migration.
It can migrate
IIS Websites
Application Pools
Server certificates
Settings of application pools
Settings of websites
Authentication modes
MIME types
Directory Browsing
Output caching
Web binaries
And other related stuff and iis settings can be migrated using web deploy.
Go through https://www.microsoft.com/en-us/download/details.aspx?id=39277
and download web deploy for your IIS.

IIS 10.0 AppPool crashing

After a company forced Windows 10 update today, the Application Pool required by a local web application keeps stopping/crashing displaying the message
Service Unavailable
HTTP Error 503. The service is unavailable.
I have checked the the below similar posts and followed the solutions provided with no luck.
#1 - https://stackoverflow.com/questions/47338226/iis-10-0-apppool-crashing-causing-503-error
For hosting .Net Core applications in IIS, .Net CLR Version of
application pool should be No Managed Code as shown in below
screenshot.
#2 - https://stackoverflow.com/questions/50244861/iis-10-app-pool-keeps-stopping-due-to-aspnetcore-dll-failed-to-load
Go to the drive your IIS is installed on, eg. C:\inetpub\temp\appPools\
Delete the directory (or virtual directory) with the same name as your app pool.
Recycle/Start your app pool again.
I have also followed the Microsoft instructions. Made sure to first follow the steps in "Turn Windows features on/off) and then installing the ASP.NET Core hosting bundle as instructed.
#3 - https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.1&tabs=aspnetcore2x
I'm not having any luck.
Here's my setup App Pool
Here's my setup Site
I've done everything I know. Does anyone have this same experience and can share a solution?
As always, a big thank you to the experts out there!
UPDATE:
I created a new AppPool with Identity "ApplicationPoolIdentity" setting. The page will run however I need to connect to a SQL Server instance with my own credentials because we use Windows authentication on most of the pages. When I create a new AppPool with my credentials it will not stay running.

IIS Virtual Directory map to network drive (with drive letter) but fail to create file

I am using C#/ASP.NET, IIS6 on Windows Server 2003.
Map the data server shared folder to the WebServer with driver letter V:\
On the WebServer, IIS created a virtual directory and pointed to 'local location' with V:\ . Since there is no 'Connect As', not sure which USER will be used
In my WebMethod, I want to create file on the shared folder with FileStream.Write().
I got IO Exception on the action, any hint?
P.S. I have added ASPNET/NETWORK SERVICE on the data server shared folder.
thanks!
Gavin
Mapped network drives are specific to the user account that created them:
Using Mapped Drives with IIS - MS KB257174
The preferred method of accessing content for the Web server that exists on a remote computer is to use shares that follow the universal naming convention (UNC).
It's very likely that NETWORK SERVICE (or if you're running ASP.NET under impersonation, the site anonymous account) hasn't got this mapping.
To change the location where the virtual directory points to, browse to your site in IIS manager, right click on the virtual directory and select properties. You can then select "A share located on another computer":
The website in IIS has a corresponding app pool and this should tell you the user under which your code wil be running.
You'll the have to grant the appropriate permissions for that share for that user.

Confused about terminology and concepts used in IIS

I am a little confused about some basic concepts about Microsoft IIS 7 (Internet Information Services). Could anyone give me concise definitions on the following terms:
Host
Site
Web Application
Virtual Directory
Application Pool
Especially: what's the difference between Site, Web Application and Virtual Directory?
Update - 1 - 8:49 AM 12/20/2010
A related topic: Difference between web site and web application
Some "quick and dirty" answers:
Host: The machine that is hosting IIS (can be a physical machine or a virtual machine).
Site: A website that is not the child of another site.
Web Application: A website. Usually if they are referred to as "web applications" then they are very data driven and it is not a static site.
Application Directory: Essentially a child website. It can have its own application pool, but settings can also be inherited from the parent website (HTTP handlers and HTTP modules for example). You didn't specifically ask about this one, but I added it as it may have been what you meant by "Web Application".
Virtual Directory: A directory of a website that has a physical location that is different than the website itself. One common use for this is to have a web farm, but some of the content is located on a shared resource (such as a SAN or NAS). This prevents the need of replicating files between all servers of a web farm. There are other purposes of a virtual directory, but this is the main reason I've used them in the past.
Application Pool: The process that a .NET application runs as. This may be used by things over than .NET, but that's the only piece I know that currently uses application pools. Essentially this holds the user and other information that the .NET application runs under. For instance, if you are using a trusted connection to SQL Server (SSPI), then by default, the user it will connect to the database as the user that this process is running as (unless you have impersonation in the web application set). This is also the user that will be used if the web application accesses system resources.

Creating a new website on IIS: Application vs. Virtual Directory. Whats the difference?

When you create a new website on IIS, you get to choose between an "Application" and a "Virtual Directory". What is the difference between those two options?
A virtual directory is just a pointer to where web pages are stored.
An Application reserves memory in IIS for your web pages. If you are attempting to run ASP pages and plan to make use of session variables and the such then you must use an application.
An Application can make use of a virtual directory or it may just exist within the default web site directory (inetpub/wwwroot/)
There are a few differences, here are the biggest:
In IIS 6 and up, you can assign an application a certain "protection" level. (e.g. protection levels, application pools, etc). You can't do this with Virtual Directories
If you are working with ASP.NET, the search for the master "Web.config" file for your application stops at your application level. For a working directory it will actually check your parent hierarchy for settings as well.
These are the two biggest differences in my opinion, although there are other small ones as well.
From the point of view of a web developer:
A virtual directory is the IIS 5 (Windows 2000 and earlier) container for HTML content. A virtual directory can also be configured to allow the interpretation of Active Server Pages (ASP) scripts and/or the execution of Common Gateway Interface (CGI) applications. A virtual directory CANNOT host an ASP.Net web application.
The "application" container type was introduced with IIS 6 (Windows XP / Windows Server 2003 and later). It allows for hosting of ASP.Net web applications.

Resources