I am attempting to create a PS Script to update or change the root level of IIS Authentication with settings for Forms Authentication and ASP.NET Impersonation. I am able to change Anonymous and Windows Authentication but I am having no luck with ASP.NET and Forms. I can change the ASP.NET and Form settings under the DefaultSiteWebSite directory but not at the localhost level. This is what I am trying but it does not work:
Forms Authentication
Set-WebConfiguration system.web/authentication 'IIS:\' -value @{mode='Forms'}
ASP.Net
$aspNetImpersonation = Get-WebConfigurationProperty -filter system.web/identity -name impersonate -location "IIS:\"
if( $aspNetImpersonation.Value -eq $true ){
Write-Host "ASP.NET Impersonation is already enabled"
} else {
$appCmdFilePath = "$Env:SystemRoot\System32\inetsrv\appcmd.exe"
& $appCmdFilePath set config "IIS:\" -section:system.web/identity /impersonate:"True"
}
}
Any idea?