Guest User

Untitled

a guest
Jul 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. Test (website) ----------------> c:InetPub
  2. SubDirectory ------------------> ..Subdirectory
  3. gadgets (Web App) -----------------> ..Gadgets
  4.  
  5. $WebSiteName = “Test”
  6. $virtualDirName = “subdirectorygadgets”
  7. $appPoolName = “DefaultAppPool”
  8. $VirtalDirHomePath = "c:InetPubSubdirectoryGadgets"
  9.  
  10. $iisWebSite = Get-WmiObject "IISWebServerSetting" `
  11. -Namespace "rootMicrosoftIISv2" `
  12. -filter "ServerComment like '%$WebSiteName%'"
  13. $virtualDirSettings = [wmiclass] "rootMicrosoftIISv2:IIsWebVirtualDirSetting"
  14. $newVDir = $virtualDirSettings.CreateInstance()
  15. $newVDir.Name = ($iisWebSite.Name + '/ROOT/' + $virtualDirName)
  16. $newVDir.Path = $VirtalDirHomePath
  17. $newVDir.Put();
  18.  
  19. $nvdir = $iisWebSite.Name + '/ROOT/' + $virtualDirName
  20.  
  21. $nvdir = $nvdir.Replace("", "/")
  22.  
  23. $v = Get-WmiObject -Class IIsWebVirtualDir -Namespace rootmicrosoftiisv2 `
  24. -filter "Name='$nvdir'"
  25.  
  26. #Create WebAppliction
  27. $v.AppCreate3(2, $appPoolName, 1)
  28.  
  29. SET webSiteName=Test
  30. SET virtualDirName=subdirectory/gadgets
  31. SET virtualDirHomePath=C:InetPubSubdirectoryGadgets
  32.  
  33. cscript %SystemRoot%system32iisvdir.vbs /create %webSiteName% %virtualDirName% %virtualDirHomePath%
  34.  
  35. cscript %SystemRoot%system32iisvdir.vbs /query %webSiteName%/%virtualDirName%
  36.  
  37. $root = [adsi] "IIS://localhost/W3SVC/1/ROOT"
  38. $vDir = $root.Create("IIsWebDirectory", "SubDirectoryGadgets")
  39. $vDir.AppCreate3(2, "DefaultAppPool", $false)
  40. $vDir.AppFriendlyName = "Andy Test"
  41. $vDir.SetInfo()
  42.  
  43. ([adsi] "IIS://localhost/W3SVC").psbase.Children | ? {$_.psbase.schemaclassname -eq "IIsWebServer" } | select Path, ServerComment
  44.  
  45. Path ServerComment
  46. ---- -------------
  47. IIS://localhost/W3SVC/1 {Default Web Site}
  48. IIS://localhost/W3SVC/2 {WHS site}
Add Comment
Please, Sign In to add comment