2

After trying to use ConvertTo-Application and New-WebApplication, I've had no luck converting a folder to an app when it's located on a network share. I receive a "Path doesn't belong to 'WebAdministration' provider"

I've scoured the internet trying to find a solution, including several links from stackoverflow. Basically I'm making a GUI script to create a website, convert folders to webapps, I have two comboboxes for selecting current websites and AppPools. The GUI also let's me create AppPools. The GUI works great, but I'm just trying to get this one feature of it going.

This feature of the script is something that is required by management.

New-WebApplication -Name $Name2 -Site $SiteN -PhysicalPath $Path -ApplicationPool $AppP

(also)

ConvertTo-WebApplication -PSPath "\\domain.local\webstuff\WebSites\Dev\Internet\foldername\scriptdevsite\scriptdevsite2\SiteApp1"

Now, I realize that ConvertTo-WebApplication is for converting Virtual Directories to apps, but I wanted to try this and see if it'll work. The New-Website command works great, but it makes apps and leaves the folders. So I'll get scriptdevsite2\SiteApp1\SiteApp1, not going to work. We have websites that have physical folders that sometimes need to be converted to an application and occasionally removed for testing.

Likely going to have to implement some C# for this, I've been checking into Application Class. But it's not very helpful, at least not to me.

I'm still new to this site, so if there's anything I'm leaving out, I apologize in advance. Thank you for your help

Kyle74
  • 31
  • 6
  • An answer I wrote a while back might help (it's based around c# and Microsoft.Web.Administration which is callable from Powershell): https://stackoverflow.com/a/4526489/419 ... if not then drop me a comment here. In that answer I cover pretty much all of the kinds of actions you'd want to perform on folders in a website. – Kev Aug 13 '19 at 20:00
  • 1
    Wow thank you @techguy1029 for the edit suggestions, looks significantly cleaner. I appreciate that :) Kev, thank you! I'm looking over that right now, I'll get back to you soon – Kyle74 Aug 13 '19 at 20:14
  • Ohhhhh shoot, ok, so I'll bet I can use Add- or Set-WebConfigurationProperty to maybe turn the folder into an app. Otherwise, I'm very, VERY green with C#, your convert folder to application section would be perfect, but how would I utilize those commands in Powershell? OH shoot, could I do an Add-Type Microsoft.Web.Administration or something? – Kyle74 Aug 13 '19 at 20:26
  • yeah you can do....`[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")` then `$iis = new-object Microsoft.Web.Administration.ServerManager` – Kev Aug 13 '19 at 20:49
  • 1
    Haha I literally just added that to my script :) Thanks again though Kev! – Kyle74 Aug 13 '19 at 20:51
  • Fabby!....this might help as well. It's a bit old, but might help translating to the world of PowerShell: https://blogs.msdn.microsoft.com/carlosag/2008/02/10/using-microsoft-web-administration-in-windows-powershell/ – Kev Aug 13 '19 at 20:52
  • Yeah that definitely helps a lot. Struggling a bit, but I'm trying :). Just trying to figure out how to use Powershell variables with what you wrote and actually using them. Hmm getting errors with the full file share path. Application $App = site.Applications.Add("/SiteApp1", @"\\domain\webdata$\WebSites\Dev\Internet\path\scriptdevsite\scriptdevsite2"); <- and it doesn't like the semi-colon – Kyle74 Aug 13 '19 at 21:29

0 Answers0