IIS7.5 PowerShell preloadEnabled
This is a bit late, but this will help others... This worked for me and was a little less verbose. The key difference is that I removed ApplicationDefaults because I am setting the application, not the defaults here:
Set-ItemProperty IIS:\Sites\<siteName>\<applicationName> -name preloadEnabled -value True
WHERE: 'SiteName' might equal Default Web Site 'ApplicationName' might equal MyApplication
There is in fact a way to do this (assuming you have a single application at / that you want to set it for and you know the name of your site):
[System.Reflection.Assembly]::LoadFrom("C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll")
$serverManager = (New-Object Microsoft.Web.Administration.ServerManager)
$serverManager.Sites["YOUR_SITE_NAME"].Applications["/"].SetAttributeValue("preloadEnabled", $true)
$serverManager.CommitChanges()
This should do the trick. You can use the get-itemproperty
to verify that it worked. It took me a while to figure out where to find preloadEnabled
within powershell but if you pipe the site path to get-member
, then you can work your way from there.
import-module webadministration
set-itemproperty IIS:\Sites\SiteName -name applicationDefaults.preloadEnabled -value True