SOURCES:
http://www.tech-faq.com/using-iis-command-line-utilities-to-manage-iis.shtml
Using IIS Command-Line Utilities to Manage IIS
The Types of Commands used for Managing IIS from the Command Line
The types of commands which you can use to manage IIS from the command line are:
- IISReset, Windows Management Instrumentation (WMI) scripts, Active Directory Services Interface (ADSI), and the standard Windows commands and Support Tools utilities.
IISReset Command-line Utility
IISReset is a command-line utility that has been in existence from IIS 5, which you can use to stop IIS, restart IIS, and reboot the IIS server. Typical reasons for restarting IIS are:
- When problematic ASP.NET and ASP application exist, and you need to eliminate resource leaks, or initiate resource recycling.
- When certain IIS configuration changes are made, you would need to restart IIS so that the changes are applied. A few of these types of configuration settings changes are listed below:
- IIS needs to be restarted when the IIS isolation mode is changed.
- When you restore the metabase from a metabase history file manually, you need to restart IIS.
- You have to restart IIS when you change the Direct Metabase Edit feature’s property, EnableEditWhileRunning, directly in the metabase file.
- IIS also has to be restarted whenever changes are made to any global configuration settings located under HKLM\Software\Microsoft\InetMgr\Parameters.
Windows Management Instrumentation (WMI)
You can use WMI scripts for a few typical IIS management tasks:
- Create and delete Web sites and FTP sites
- Create and delete virtual directories
- Enable/disable web service extensions
- Backup and restore IIS configuration, and copy IIS configuration
- Import/export portions of the metabase, as well as other management tasks
A few WMI scripts are provided by Microsoft, and are located in the \Windows\System32 directory. These WMI scripts and their associated functions are listed below:
- iisweb.vbs: Used to perform the following management tasks from the command line:
- List Web sites
- Create/delete Web sites
- Start/stop Web sites
- iisvdir.vbs: Used for performing the following management tasks from the command line:
- Create/delete virtual directories for Web sites
- List virtual directories in a specified root.
- iisapp.vbs: For listing all Web applications which are running on the IIS machine.
- iisback.vbs: For backing up and restoring IIS configuration settings, and for deleting IIS backups.
- iiscnfg.vbs: Used to perform the following management tasks from the command line:
- Import and export IIS configurations as XML files
- Save IIS configuration to disk.
- Copy IIS configuration settings
- iisext.vbs: Used for performing the following management tasks from the command line:
- List applications
- Enable applications
- Add/remove application dependencies
- Enable/disable web service extensions
- List and add/remove web service extension files
- Enable/disable web service extension files
- iisftp.vbs: Used to perform the following management tasks from the command line:
- List FTP sites
- Create/delete FTP sites
- Start/stop FTP sites
- Set Active Directory user isolation for your FTP sites
- iisftpdr.vbs: Used to perform the following management tasks from the command line:
- Create and delete virtual directories in FTP sites
- List virtual directories in a specified root.
Active Directory Services Interface (ADSI)
Active Directory Services Interface (ADSI) was used in IIS 5 to manage IIS from the command line. Through ADSI, you can change IIS configuration settings, and configure websites, applications, and virtual directories from the command line. With IIS 6, it is recommended to use WMI scripts over ADSI. Any custom ADSI scripts previously used in IIS 5 should be tested to verify that they work in IIS 6.
Windows Commands and Support Tools Utilities
A few IIS specific Windows commands, such as the net commands, can be used to manage IIS from the command line:
- net start and net stop: Used to start and stop IIS services. The service name which you should use when utilizing the net command to start, or stop IIS services are listed below:
- FTP service = msftpsvc
- IIS Admin service = iisadmin
- NNTP service = nntpsvc
- SMTP service = smtpsvc
- WWW service = w3svc
- net localgroup: Used to add a user account to the IIS_WPG group. Accounts utilized as application pool identities are members of the IIS_WPG group.
- Cacls: Used to capture NTFS permissions on the IIS server.
- Convlog: Used to convert the IIS log files to the NCSA format.
You can also use the resource kit utilities listed below to manage certain elements of IIS:
- secedit: Used to administer security templates.
- auditpol: Used to change audit policies from the command line
- showmbrs: Used to list the members of security groups which have permissions on directories and files.
How to schedule IISReset.exe through Task Scheduler
IISReset is typically used when you need to recover from faulty application situations. You can use Windows Task Scheduler to schedule IIS to restart according to predefined parameters.
- Open Control Panel.
- Select Scheduled Tasks, and then select Add Scheduled Task.
- Click Next for the Scheduled Task Wizard to start.
- Click Browse and browse to Windows\System32 folder.
- Double-click IISReset.exe.
- Enter a task name, and select when the task should run. Click Next.
- Enter the Administrator account details that should be utilized to run IISReset. Click Next.
- If you want to configure advanced task scheduling properties, click the Advanced checkbox; or alternatively click Finish.
- Open the Properties dialog box of the task you just configured, and click the Task tab.
- Add any additional switches in the Run box.
- Click OK.
How to use iisweb.vbs to manage Web sites
The iisweb.vbs utility is used to list Web sites, create and delete Web sites, and start and stop Web sites in IIS.
iisweb.vbs has the following main switches:
/create
, for creating a Web site.
/delete
, for deleting a Web site.
/start
, for starting a Web site.
/stop
, for stopping a Web site
/pause
, for pausing a Web site
/query
, for troubleshooting a Web site - displaying all the Web sites on the IIS machine
To create a Web site, use:
iisweb[.vbs] /create Path SiteName [/b Port] [/i IPAddress] [/d HostHeader] [/dontstart] [/s Computer [/u [Domain\]User [/p Password]]]
Path
, the physical location to the files for the Web site. When the directory does not exist, the script creates it.
SiteName
, the name of the new Web site. This is the name which will be displayed in IIS Manager.
/b Port
, the port on which the new Web site should listen for HTTP requests. The default value is port 80.
/i
IPAddress, the IP address that must be assigned to the Web site.
/d
HostHeader, the host header for the new site.
/dontstart
, used to indicate that IIS should not automatically start the Web site after it is created. IIS by default starts a newly created Web site.
/s Computer
, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]User
, the account credentials that must be used to create the Web site on the remote computer.
/p Password
, the password of the account credentials (above).
To start, stop, delete, or pause a Web site, use:
iisweb[.vbs] {/delete | /start | /stop | /pause} WebSite [WebSite...] [/s Computer [/u [Domain\]User [/p Password]]]
WebSite
, the name of the Web site which should be deleted, started, stopped, or paused.
/s Compute
r, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]User
, the account credentials that must be used to delete, start, stop, or pause the Web site on the remote computer.
/p Password
, the password of the account credentials (above).
To query Web sites on your IIS servers, use
iisweb[.vbs] /query [WebSite [WebSite...]] [/s Computer [/u [Domain\]User [/p Password]]]
How to use iisvdir.vbs to manage virtual directories
The iisvdir.vbs command can be used to list virtual directories in a specified root, to create and delete virtual directories for websites, and to query virtual directories of an IIS server.
To create a virtual directory for a Web site, use:
iisvdir /create WebSite[/VirtualPath] Name PhysicalPath [/s Computer [/u [Domain\]User /p Password]]
WebSite
, the name of the Web site which you want to create the virtual directory for.
VirtualPath
, the virtual path under which this virtual directory should be created (optional)
Name
, the name of the new virtual directory.
PhysicalPath
, the name of physical directory where the virtual directory points.
/s Computer
, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]User
, the account credentials that must be used to create the virtual directory for the remote computer.
/p Password
, the password of the account credentials (above).
To delete a virtual directory associated with a Web site, use:
iisvdir /delete WebSite[/VirtualPath] Name [/s Computer [/u [Domain\]User/p Password]]
WebSite
, the name of the Web site which is associated with the virtual directory that you want to delete.
VirtualPath
, the virtual path which holds the virtual directory (optional).
Name
, the name of the virtual directory that you want to delete.
/s Computer
, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]Use
r, the account credentials that must be used to delete the virtual directory.
/p Password
, the password of the account credentials (above).
To query Web site specific virtual directories on your IIS servers, use
iisvdir /query WebSite[/VirtualPath][/s Computer [/u [Domain\] User/p Password]]
WebSite
, the name of the Web site which is associated with the virtual directory that you want to query.
VirtualPath
, the virtual path which holds the virtual directory (optional).
/s Computer
, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]User
, the account credentials that must be used to query for virtual directories.
/p Password
, the password of the account credentials (above).
How to use iisftp.vbs to manage FTP sites
The iisftp.vbs utility is used to perform management tasks from the command line that are specific to managing FTP sites on the IIS servers.
iisftp.vbs has the following main switches:
/create
, for creating a FTP site.
/delete
, for deleting a FTP site.
/start
, for starting a FTP site.
/stop
, for stopping a FTP site
/query
, for troubleshooting a FTP site - displaying all the FTP sites on the IIS machine
/setadprop
, for indicating that Active Directory properties should be used for a particular user accessing the FTP site.
/getadprop
, for obtaining Active Directory properties for the particular user.
To create a FTP site, use:
iisftp /create Path SiteName [/b Port] [/i IPAddress] [/dontstart] [/isolation {AD|Local} [/domain DomainName /Admin [Domain\]User /AdminPwd Password]] [/s Computer [/u [Domain\]User/p Password]]
Path
, the physical location to the files for the FTP site.
SiteName
, the name of the new FTP site. This is the name which will be displayed in IIS Manager.
/b Port
, the port on which the new FTP site should listen for FTP requests. The default value is port 21.
/i IPAddress
, the IP address that must be assigned to the FTP site.
/dontstart
, used to indicate that IIS should not automatically start the FTP site after it is created. IIS by default starts all newly created sites.
/isolation
, used to indicate the isolation mode that should be used.
domain
, when Active Directory is selected as the isolation mode, this is the domain for Active Directory.
admin
, when Active Directory is selected as the isolation mode, this is the admin account credentials for Active Directory.
AdminPwd
, when Active Directory is selected as the isolation mode, this is the password of the admin account for Active Directory (above).
/s Computer
, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]User
, the account credentials that must be used to create the FTP site on the remote computer.
/p Password
, the password of the account credentials (above).
To start, stop, delete, or pause a FTP site, use:
iisftp[.vbs] {/delete | /start | /stop | /pause} FTPSite [FTPSite...] [/s Computer [/u [Domain\]User [/p Password]]]
FTPSite
, the name of the FTP site which should be deleted, started, stopped, or paused.
/s Computer
, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]User
, the account credentials that must be used to delete, start, stop, or pause the FTP site on the remote computer.
/p Password
, the password of the account credentials (above).
To query FTP sites on your IIS servers, use
iisftp[.vbs] /query [FTPSite [FTPSite...]] [/s Computer [/u [Domain\]User [/p Password]]]
To use /setadprop, and /getadprop use,
iisftp /SetADProp UserID {FTPDir|FTPRoot} PropertyValue [/s Computer [/u [Domain\]User/p Password]]
iisftp /GetADProp UserID [/s Computer [/u [Domain\]User /p Password]]
UserID
, the Active Directory user login ID
FTPDir
, indicates whether the modification is applicable at the directory level or at the root level.
PropertyValue
, indicates the home directory and relative path.
/s Computer
, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]User
, the account credentials that must be used for remote administration.
/p Password
, the password of the account credentials (above).
How to use iisftpdr.vbsto manage virtual directories
The iisftpdr.vbs command can be used to list virtual directories in a specified root, and to create and delete virtual directories in FTP sites from the command line.
To create a virtual directory for a FTP site, use:
iisftpdr /create FTPSite[VirtualPath] Name PhysicalPath [/s Computer [/u [Domain\]User /p Password]]
FTPSite
, the name of the FTP site which you want to create the virtual directory for.
VirtualPath
, the virtual path under which this virtual directory should be created (optional)
Name
, the name of the new virtual directory.
PhysicalPath
, the name of physical directory where the virtual directory points.
/s Computer
, used to indicate that the script should run on this remote computer. The local computer is used by default.
/u [Domain\]User
, the account credentials that must be used to create the virtual directory on the remote computer.
/p Password
, the password of the account credentials (above).
To delete a virtual directory associated with a FTP site, use:
iisftpdr /delete FTPSite[VirtualPath]/Name [/s Computer [/u [Domain\]User /p Password]]
- FTPSite, the name of the FTP site which is associated with the virtual directory that you want to delete.
- VirtualPath, the virtual path which holds the virtual directory (optional).
- Name, the name of the virtual directory that you want to delete.
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to delete the virtual directory.
- /p Password, the password of the account credentials (above).
To query FTP specific virtual directories on your IIS servers, use
iisftpdr /query FTPSite[/VirtualPath][/s Computer [/u [Domain\]User/p Password]]
- FTPSite, the name of the FTP site which is associated with the virtual directory that you want to query.
- VirtualPath, the virtual path which holds the virtual directory (optional).
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to query for virtual directories remotely.
- /p Password, the password of the user account (above).
How to use iiscnfg.vbs to manage IIS from the command line
You can use iiscnfg.vbs to import and export IIS configurations settings of the metabase as XML files.
To export IIS configuration settings, use:
iiscnfg /export /f [Path\]FileName.xml /sp SourcePath [/d EncryptingPassword] [/inherited] [/children] [/s Computer [/u [Domain\]User [/p Password]]]
- /f [Path\]FileName.xml, the name of the XML file that the configuration settings should be exported to.
- /sp SourcePath, the node of the metabase configuration settings.
- /d EncryptingPassword, the password of the XML file.
- /inherited, indicates that all inherited information should be exported.
- /children, indicates that subkeys of the node should be exported.
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to run the script.
- /p Password, the password of the account credentials (above).
To import IIS configuration settings, use:
iiscnfg /import /f [Path\]FileName.xml /sp SourcePath /dp DestinationPath [/d EncryptingPassword] [/inherited] [/children] [/merge][/s Computer [/u [Domain\]User [/p Password]]]
- /f [Path\]FileName.xml, the name of the XML file that should be used to import IIS configuration settings to the server.
- /sp SourcePath, the node of the XML file.
- /dp DestinationPath, the destination node path in the metabase.
- /d EncryptingPassword, the password of the XML file.
- /inherited, indicates that all inherited information should be imported. This can only occur when the source node has properties that can be inherited.
- /children, indicates that subkeys of the node should be imported.
- /merge, merges different source keys to one metabase key through this value.
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to run the script.
- /p Password, the password of the user account (above).
To copy the metabase.xml file and metabase XML file to a different IIS server, use:
iiscnfg /copy /ts TargetComputer /tu TargetUser /tp TargetPassword [/s Computer [/u [Domain\]User [/p Password]]]
- /ts TargetComputer, the name or IP address of the IIS computer to which these configuration settings should be copied.
- tu TargetUser, the user account for logging on the target computer.
- tp TargetPassword, the password of the account provided above.
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to run the script remotely.
- /p Password, the password of the account (above).
To immediately save configuration changes to the metabase, use:
iiscnfg /save [/s Computer [/u [Domain\]User /p Password]]
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to run the script.
- /p Password, the password of the account (above).
How to use iisback.vbs to back up IIS configuration settings and restore IIS configurations
You can use iisback.vbs to back up, and restore IIS configuration settings from the command line
To back up IIS configuration settings, use:
iisback /backup [/b BackupName] [/v {Integer | HIGHEST_VERSION | NEXT_VERSION}] [/overwrite] [/e EncryptingPassword] [/s Computer [/u [Domain\]User/p Password]]
- /b BackupName, the name of the back up.
- /v {Integer}, possible values are HIGHEST_VERSION or NEXT_VERSION. HIGHEST_VERSION creates a backup of the highest version number. The HIGHEST_VERSION value has to be utilized with /overwrite. NEXT_VERSION increments the existing version number by one.
- /overwrite, used to overwrite a current backup
- /e EncryptingPassword, used to enable password encryption for the backup.
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to create backups for the remote computer.
- /p Password, the password of the account credentials (above).
To restore IIS configuration settings, use:
iisback /restore /b BackupName [/v {Integer | HIGHEST_VERSION}] [/e EncryptionPassword] [/s Computer [/u [Domain\]User/p Password]]
- /b BackupName, the name of the backup file that you want to restore.
- /v {Integer}, possible values are HIGHEST_VERSION or NEXT_VERSION.
- /e EncryptingPassword, the password for the backup.
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to restore the backup file for the remote computer.
- /p Password, the password of the account (above).
To list all IIS backups for an IIS server, use:
iisback /list [/s Computer [/u [Domain\]User/p Password]]
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to list all backups for the remote computer.
- /p Password, the password of the account credentials (above).
To delete an IIS backup, use:
iisback /delete [/bBackupName] [/v {Integer | HIGHEST_VERSION}] [/s Computer [/u [Domain\]User /p Password]]
- /bBackupName, the name of the backup file that you want to delete.
- /v {Integer}, possible values are HIGHEST_VERSION or NEXT_VERSION.
- /s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.
- /u [Domain\]User, the account credentials that must be used to delete the backup file for the remote computer.
- /p Password, the password of the account credentials (above).
Bookmark Using IIS Command-Line Utilities to Manage IIS