Ramuk Navap
Ramuk Navap

Reputation: 1

How to make a created virtual directory in IIS6.0 as application using powershellv2.0

HI i created some virtual directories in my iis using following code

Function InputBox ($message, $title, $default)
{
    [void][reflection.assembly]::loadwithpartialname("microsoft.visualbasic")
    $result = [microsoft.visualbasic.interaction]::InputBox($message,$title, $default)

    return $result
}

$server=inputbox("enter the name of the server")
$iis=[adsi]"IIS://$($server)/W3SVC/1/Root"
$vdirname=inputbox("enter the name of virtual directory","","")
$vd = $iis.psbase.children.Add($vdirname,"IISWebVirtualDir")
$vdirpath=inputbox("enter the physical location of the application")
$vd.put("Path",$vdirpath)
$vd.psbase.CommitChanges()

but i am unable to create it as an application can any one help me out in this issue. for creating it as an application i am going into the properties of the virtual directory and in the virtual derctory tab in the application sessions, i clicked on "create" button and then application got created.

can any one help me with a powershell code that will create an application Thanks, Ramuk Navap

Upvotes: 0

Views: 1216

Answers (2)

Keith Hill
Keith Hill

Reputation: 202052

Use the WebAdministration module that comes with PowerShell 2.0:

Import-Module WebAdministration
New-WebVirtualDirectory -Site "Default Web Site" -Name ContosoVDir `
                        -PhysicalPath c:\inetpub\contoso

If you copy/paste this make sure there is no additional whitespace after the line continuation character - (`).

Upvotes: 1

Related Questions