Note that there are some explanatory texts on larger screens.

plurals
  1. POPowershell : How to create IIS 6 Virtual Directory/Web application under a Subfolder
    primarykey
    data
    text
    <p>I am trying to create a Web application/VirtualDirectory under a specific subfolder of a IIS 6 website using Powershell as show below:</p> <h3>IIS WebSite Structure &lt;&lt;&lt;>>> Physical Directory Structure</h3> <pre><code>Test (website) ----------------&gt; c:\InetPub SubDirectory ------------------&gt; ..\Subdirectory gadgets (Web App) -----------------&gt; ..\Gadgets </code></pre> <hr> <h3>Script</h3> <pre><code>$WebSiteName = “Test” $virtualDirName = “subdirectory\gadgets” $appPoolName = “DefaultAppPool” $VirtalDirHomePath = "c:\InetPub\Subdirectory\Gadgets" $iisWebSite = Get-WmiObject "IISWebServerSetting" ` -Namespace "root\MicrosoftIISv2" ` -filter "ServerComment like '%$WebSiteName%'" $virtualDirSettings = [wmiclass] "root\MicrosoftIISv2:IIsWebVirtualDirSetting" $newVDir = $virtualDirSettings.CreateInstance() $newVDir.Name = ($iisWebSite.Name + '/ROOT/' + $virtualDirName) $newVDir.Path = $VirtalDirHomePath $newVDir.Put(); $nvdir = $iisWebSite.Name + '/ROOT/' + $virtualDirName $nvdir = $nvdir.Replace("\", "/") $v = Get-WmiObject -Class IIsWebVirtualDir -Namespace root\microsoftiisv2 ` -filter "Name='$nvdir'" #Create WebAppliction $v.AppCreate3(2, $appPoolName, 1) </code></pre> <p>If I specify the <code>$virtualDirName</code> with forward slash path separator (<code>subdirectory/gadgets</code>) , <code>$newVDir.Put()</code> call throws following exception</p> <blockquote> <p>Exception calling "Put" with "0" argument(s): "Win32: The system cannot find the path specified.</p> </blockquote> <p>If I change the <code>$virtualDirName</code> with backslash path separator (subdirectory\gadgets) <code>$newVDir.Put()</code> call returns successfully.</p> <p>I am not sure whether this is the right way.</p> <p>Is there any better way to create Web Application/VirtualDirectory under a specific subfolder and How can I list VirtualDirectory/WebApplication created under a subfolder.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload