I'm using the PowerShell script below to set anonymous user identity and authentication methods on an IIS6 server. The script seems to work at first, but if I issue an iisreset after running it the values revert to the old ones! How do I persist them?
$server = "localhost"
$siteName = "www.mysite.com"
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.children | where { $_.keyType -eq "IIsWebServer" -and $_.ServerComment -eq $siteName }
$path = [ADSI]($site.path+"/ROOT")
$path.AnonymousUserName = "user"
$path.AnonymousUserPass = "pass"
$path.AuthFlags = 3
$path.CommitChanges()