How to setup default document for a IIS website from command prompt? - iis

I want to set default document for a IIS website from command prompt.
May I know how to setup this..
Thanks,
Mahesh

You can use appcmd.exe:
appcmd set config /section:defaultDocument /enabled:true|false
Check appcmd help at MSDN (or here) for more information.
http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe

Related

Set mailroot directories for IIS SMTP

Using IIS 7.5 on Windows Server 2008 R2
I need to change the default location for ALL SMTP directories (default locations shown below):
C:\inetpub\mailroot\Badmail
C:\inetpub\mailroot\Drop
C:\inetpub\mailroot\Pickup
C:\inetpub\mailroot\Queue
to the following:
D:\smtp\badmail
D:\smtp\drop
D:\smtp\pickup
D:\smtp\queue
The ONLY directory which is configurable via Start -> Administrative Tools -> Internet Information Services IIS (6.0) Manager is the "Badmail" directory -- a new directory can be entered directly using the IIS (6.0) Manager.
No other option is available for the other 3 directories.
Is there any way to change these directories WITHOUT:
a) Having to install adsutil.vbs?
Is it possible to change these via Powershell?
Did I miss something or some other utility that can do this?
Any help/advice would be appreciated.
Thanks in advance
I going to try to answer my own question... Can anyone (Microsoft) verify if this is correct before I try this little plan?
Start -> Administrative Tools -> Internet Information Services IIS (6.0) Manager
Right-click on sever name and select "Properties"
Check box labeled "Enable Direct Metabase Edit" -> Click OK
Stop the SMTP site.
Using NotePad, open the MetBase file located at C:\Windows\System32\inetsrv\MetaBase.xml
Update the locations for the "Badmail", "Drop", "Pickup" and "Queue" directories. Save file.
Start the SMTP site.
From this point forward, the new directories should be used -- correct?
I didn't find that the accepted answer worked for me in IIS 8.5 Windows Server 2012 R2, but I did find a solution that worked. It requires using the adsutil.vbs that gets installed if you add the feature under the add roles or features wizard - features - management tools - iis6 management compatibility - iis6 scripting tools:
ref. https://www.itnota.com/moving-default-smtp-folders-to-different-drive-windows-server/
Launch Command Prompt (Admin) and run these commands:
net stop smtpsvc
set util=C:\inetpub\AdminScripts\adsutil.vbs
set dst=D:\smtp\
robocopy c:\inetpub\mailroot %dst% /e /copyall /dcopy:T /move
cscript.exe %util% set smtpsvc/1/badmaildirectory %dst%Badmail
cscript.exe %util% set smtpsvc/1/dropdirectory %dst%Drop
cscript.exe %util% set smtpsvc/1/pickupdirectory %dst%Pickup
cscript.exe %util% set smtpsvc/1/queuedirectory %dst%Queue
net start smtpsvc
This only moves folders and sets paths for the first SMTP virtual server. For others, change "smtpsvc/1/" to "smtpsvc/2/", and possibly comment out the robocopy depending on how your paths were configured for the other smtp virtual servers.

How to add a application pool in iis by command line?

I want to create a application pool in IIS by using command line. I don't know the command line to create it. Please help me if you did.Thanks so much!
Even easier if you use New-WebAppPool from the Web Server (IIS) Administration Cmdlets.

Is there a way to reset IIS 7.5 to factory settings?

I modified a lot of options in IIS, and would like to reset its settings to default.
I already tried installing/reinstalling it. After the reinstall, it still had the site I created. It was still breaking on the setting I made to the DefaultWebSite.
People suggested uninstalling Windows Process Activation Service first, but it seems like it wasn't installed anyway, so I can't really uninstall it.
How can I reset this installation of IIS back to an out-of-the-box state?
You need to uninstall IIS (Internet Information Services) but the key thing here is to make sure you uninstall the Windows Process Activation Service or otherwise your ApplicationHost.config will be still around. When you uninstall WAS then your configuration will be cleaned up and you will truly start with a fresh new IIS (and all data/configuration will be lost).
There are automatic backup under %systemdrive%\inetpub\history but it may not help much if you already made lots of changes.
http://blogs.iis.net/bills/archive/2008/03/24/how-to-backup-restore-iis7-configuration.aspx
You will have to regularly back up manually using appcmd.
If you try to reinstall IIS, please first uninstall IIS and WAS via Add/Remove Programs, and then delete all existing files under C:\inetpub and C:\Windows\system32\inetsrv directories. Then you can install again cleanly.
WARN: beginners on IIS are not recommended to execute the steps above without a full backup of the system. The steps should be executed with caution and good understanding of IIS. If you are not capable of or you have doubt, make sure you open a support case with Microsoft via http://support.microsoft.com and consult.
What worked for me was going to the article someone else had already mentioned, but keying on this piece:
application.config.backup is not created by automatic backup. The backup files are in %systemdrive%\inetpub\history directory. Automatic backup is also a Vista SP1 and above feature. More information can be found in this blog post, http://blogs.iis.net/bills/archive/2008/03/24/how-to-backup-restore-iis7-configuration.aspx
I was able to find backups of my settings from when I had first installed IIS, and just copy and replace the files in the inetsrv\config directory.
Source: http://forums.iis.net/t/1085990.aspx
There is one way that I have used my self. Go to Control Panel\Programs\Turn Windows features on or off then uninstall IIS and all of its components completely. I restart windows but I'm not sure if it's required or not. Then install it again from the same path.
This link has some useful suggestions:
http://forums.iis.net/t/1085990.aspx
It depends on where you have the config settings stored. By default
IIS7 will have all of it's configuration settings stored in a file
called "ApplicationHost.Config". If you have delegation configured
then you will see site/app related config settings getting written to
web.config file for the site/app. With IIS7 on vista there is an
automatica backup file for master configuration is created. This file
is called "application.config.backup" and it resides inside
"C:\Windows\System32\inetsrv\config" You could rename this file to
applicationHost.config and replace it with the applicationHost.config
inside the config folder. IIS7 on server release will have better
configuration back up story, but for now I recommend using APPCMD to
backup/restore your configuration on regualr basis. Example: APPCMD
ADD BACK "MYBACKUP" Another option (really the last option) is to
uninstall/reinstall IIS along with WPAS (Windows Process activation
service).
Resetting IIS
On the computer that is running Microsoft Dynamics NAV Web Server components, open a command prompt as an administrator as follows:
a. From the Start menu, choose All Programs, and then choose Accessories.
b. Right-click Command Prompt, and then choose Run as administrator.
At the command prompt, type the following command to change to the Microsoft.NET\Framework64\v4.0.30319 folder, and then press Enter.
cd\Windows\Microsoft.NET\Framework64\v4.0.30319
At the command prompt, type the following command, and then press Enter.
aspnet_regiis.exe -iru
At the command prompt, type the following command, and then press Enter.
iisreset

How do you configure IIS5 advanced settings from command line?

I am trying to automate some of the build process for my asp.net apps by creating the virtual directories it needs and setting all their settings in a batch file. So far I have been able to figure out how to create virtual directories, but how to do you configure them beyond that?
For example I need to be able to set them as an application, set the default document, change framework version, turn on integrated authentication, etc. Does anyone know of any scripts that can do all this without a third party utility? Does the adsutil.vbs admin script do any of this?
Thanks, that documentation helped a lot. I wanted to post the script I ended up with. It generates the virtual directory, sets access settings, makes it an application, sets its isoloation level, sets default document, sets authentication, and even sets the framework version. Its everything I have been looking for. It does it all with the admin scripts that come with IIS5.
mkwebdir -c LocalHost -w "Default Web Site" -v "myvirdirectory","C:\Website Path\..."
adsutil APPCREATEINPROC w3svc/1/root/myvirdirectory
adsutil SET w3svc/1/root/myvirdirectory/AppFriendlyName myvirdirectory
adsutil SET w3svc/1/root/myvirdirectory/AccessScript True
adsutil SET w3svc/1/root/myvirdirectory/AppIsolated 2
adsutil SET w3svc/1/root/myvirdirectory/AuthAnonymous True
adsutil SET w3svc/1/root/myvirdirectory/AuthNTLM False
adsutil SET w3svc/1/root/myvirdirectory/AuthBasic False
adsutil SET w3svc/1/root/myvirdirectory/DefaultDoc index.aspx
adsutil SET w3svc/1/root/myvirdirectory/EnableDefaultDoc True
%windir%\microsoft.net\framework\v2.0.50727\aspnet_regiis -s w3svc/1/root/myvirdirectory
Look at http://msdn.microsoft.com/en-us/library/ms524830%28VS.90%29.aspx and http://msdn.microsoft.com/en-us/library/ms524579%28VS.90%29.aspx.

Configuring IIS 6.0 to execute cgi(.exe)

I already create a virtual directory (cgi-bin) with permission : Scripts and Executable...
When I test : http://localhost/cgi-bin/mapserv.exe, I got 404 error, The page cannot be found
Am I supposed to Add a EXTENSION mapping to .exe files ? Which executable ?
Thanks!
I solved that:
Go to Web Service Extensions in the IIS service manager
Select Add a new web service extension. On the required files tab, add
C:\YourMapserverInstalldir\mapserv.exe
Set it to allow
Thanks anyway...
Yes, you will have to create an application mapping between the file name extension of your script and the script interpreter. Check out this link.
Installing CGI Applications in IIS 6.0

Resources