Just a quick note to let you, PoSH lovers , know that if you are adding managed paths to an SPWebApplication object using PoSH , for adding an SPPrefix object to the existing SPPrefixCollection , you need to specify one of the following arguments (without space), otherwise you get a conversion error to type “Microsoft.SharePoint.Administration.SPPrefixType” due to invalid enumeration value:
In the following example, I am creating a sample Web application using the best defaults that SharePoint can determine (Thanks to SPWebApplicationBuilder!).I don’t care about setting any properties for my SPWebApplication. I then go ahead and immediately after the web application is provisioned (appears in IIS as a site) I add a managed path. Again , DO NOT forget to call Update() method on SPWebApplication object to serialize its state and propagate changes throughout your server farm. No different than when you write managed code against the SharePoint object model!
- $farm = [microsoft.sharepoint.administration.spfarm]::local
- $webAppBuilder = new-object Microsoft.SharePoint.Administration.SPWebApplicationBuilder $farm
- Write-Host "The following lines may take up several minutes. . ."
- $webApp = $webAppBuilder.Create()
- Write-Host "Addding a managed path with explicit inclusion. . ."