I have a WebSite running with WebDav in Windows server 2012, it contains 10,000 web applications, it is working properly, recently I would like to migrate it to Windows server 2019, I use poweshell scripts to bulk create 10,000 web applications and change the parameter of Authentication and WebDAV Authoring Rules Value, however, it takes time to run, for example, it takes 4 seconds for one account at the beginning, after generated 5000 accounts, it takes 7 seconds for one account, finally, it takes around 15 seconds for last account, it run slower and slower, after 10,000 applications created, the WebSite even can't start, the W3SVC service keep stopping. Can I simplify the script to let it run faster? is there any limitation on IIS 10 in Windows Server 2019? please note that the web server is running in VM environment and higher CPU and RAM resources than existing Windows 2012, besides, I also try to use appcmd.exe or vb script to bulk create the web applications, but it also takes time to run.
Import-Csv Account.csv | ForEach-Object {
New-WebApplication -Site " WebSite" -Name "$($_.User)" -PhysicalPath "$($_.Path)"
Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/anonymousAuthentication' -Location " WebSite/$($_.User)" -Name enabled -Value False
Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/basicAuthentication' -Location " WebSite/$($_.User)" -Name enabled -Value True
Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/basicAuthentication' -Location " WebSite/$($_.User)" -Name defaultlogondomain -Value 'company.com'
Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/basicAuthentication' -Location " WebSite/$($_.User)" -Name realm -Value 'company.com'
Add-WebConfiguration -Filter '/system.webServer/webdav/authoringRules' -Location " WebSite/$($_.User)" -Value @{path="*";users="company\$($_.User)";access="Read,Write,Source"}
}