Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 811829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:06:21+00:00 2026-05-15T01:06:21+00:00

I can create an IISWebVirtualDir or IISWebVirtualDirSetting with WMI, but I’ve found no way

  • 0

I can create an IISWebVirtualDir or IISWebVirtualDirSetting with WMI, but I’ve found no way to turn the virtual directory into an IIS Application. The virtual directory wants an AppFriendlyName and a Path. That’s easy because they’re part of the …Setting object. But in order to turn the virtual directory into an App, you need to set AppIsolated=2 and AppRoot=[its root].

I cannot do this with WMI. I’d rather not mix ADSI and WMI, so if anyone can coach me through to amking this happen in WMI I’d be very happy.

Here’s my demo code:

$server = 'serverName'
$site = 'W3SVC/10/ROOT/'
$app = 'AppName'
# If I use these args, the VirDir is not created at all. Fails to write read-only prop
# $args = @{'Name'=('W3SVC/10/ROOT/' + $app); `
#    'AppIsolated'=2;'AppRoot'='/LM/' + $site + $app}
# So I use this single arg
$args = @{'Name'=($site + $app)}
$args # Look at the args to make sure I'm putting what I think I am
$v = set-wmiinstance -Class IIsWebVirtualDir -Authentication PacketPrivacy `
    -ComputerName $server -Namespace root\microsoftiisv2 -Arguments $args
$v.Put()
# VirDir now exists

# Pull the settings object for it and prove I can tweak it
$filter = "Name = '" + $site + $app + "'"
$filter
$v = get-wmiobject -Class IIsWebVirtualDirSetting -Authentication PacketPrivacy `
    -ComputerName $server -Namespace root\microsoftiisv2 -Filter $filter
$v.AppFriendlyName = $app
$v.Put()
$v
# Yep. Changes work. Goes without saying I cannot change AppIsolated or AppRoot

# But ADSI can change them without a hitch
# Slower than molasses in January, but it works
$a = [adsi]("IIS://$server/" + $site + $app)
$a.Put("AppIsolated", 2)
$a.Put("AppRoot", ('/LM/' + $site + $app))
$a.Put("Path", "C:\Inetpub\wwwroot\news")
$a.SetInfo()
$a

Any thoughts?

Update with working code

 $server = 'serverName'
$site = 'W3SVC/11/ROOT/'
$app = 'AppName'
$path = "c:\inetpub\wwwroot\news"

$args = @{'Name'=($site + $app)}
$v = set-wmiinstance -Class IIsWebVirtualDir -Authentication PacketPrivacy 
  -ComputerName $server -Namespace root\microsoftiisv2 -Arguments $args
$v.AppCreate2(2)


$filter = "Name = '" + $site + $app + "'"
$v = get-wmiobject -Class IIsWebVirtualDirSetting -Authentication PacketPrivacy 
 -ComputerName $server -Namespace root\microsoftiisv2 -Filter $filter
$v.AppFriendlyName = $app
$v.Path = $path
$v.Put()

Thanks Garrett and Glenn.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:06:21+00:00Added an answer on May 15, 2026 at 1:06 am

    This is not tested, but how about something along these lines:

    $appCreateParams = $v.PSBase.GetMethodParameters("AppCreate2")
    $appCreateParams["AppMode"] = 2
    
    $v.PSBase.InvokeMethod("AppCreate2", $appCreateParams, null)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can create a block that will extract hash elements and turn them into
I can create a contact that is not mail enabled, but how do I
I can create an array of buttons in Windows Form but how can i
I can create new Silverlight App with .NET RIA Services enabled. But when I
I have a web application that deploys with two virtual directories under it's IIS
I can create .o file with g++ -c test.cpp -std=c++0x , but cant link
I have a configuration page that needs to create a virtual directory under a
How can create .csv file in android application, in which we will store some
We can create Alarm using ScheduledActionService . But there are 2 buttons on it:
I can create forms via templates with no problem. I found a plugin (create-page)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.