How to set ID attribute in IIS web-sites through windows powershell command

Viewed 2124
1 Answers

Outside of a ServerManager context, most EXISTING site properties are read-only. So while you can inspect them, you can use a ServerManager object to change them.

Powershell Example: Change site with Id 5 to Id 7, then change site "Default Web Site" to Id 99

Import-Module WebAdministration
$sm = Get-IISServerManager
$site = $sm.Sites | ? { $_.Id -eq 5 }
$site.Id = 7
$sm.CommitChanges()
$site = $sm.Sites | ? { $_.Name -eq "Default Web Site" }
$site.Id = 99
$sm.CommitChanges()
Related