0

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"} 
}

1 Answers1

0

It is obvious slow, because for each of the Set-x lines IIS configuration is read, modified and saved.

If you use the new IISAdministration cmdlets and get an instance of ServerManager to modify the settings, you can save all changes in one shot and it is much quicker when you have tons of settings to update,

https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/iisadministration-powershell-cmdlets#iisadministration-overview

Lex Li
  • 60,503
  • 9
  • 116
  • 147
  • You can try to use `msdeploy.exe` to transfer your website from WS2012 to WS2019, including all separate applications in one go. Take a look at `-verb:sync`, `-source:appPoolConfig` and `-dest:appPoolConfig`. – Jan Reilink Mar 01 '22 at 15:28
  • @JanReilink to be in good manner you should post your own answer, no lingering under another answer. – Lex Li Mar 01 '22 at 15:30
  • @LexLi, Thanks for your reply, I still don't understand, may you help to modify my script for one account by using new `IISAdminstration`? – Eddie Lam Mar 02 '22 at 11:36
  • @EddieLam you might wait and see if anyone else would like to do you a favor. – Lex Li Mar 02 '22 at 17:10