tags:

views:

73

answers:

2

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

A: 

http://arcware.net/creating-iis-applications-with-powershell

http://learn.iis.net/page.aspx/433/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools/

onder
i tried the commands in it to create applications but not workedi think it needs powershell snap-in but i have to use powershell onlyso can u please guide me in this regard
Ramuk Navap
A: 

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 - (`).

Keith Hill