Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $AppPoolSettings = [wmiclass]'rootMicrosoftIISv2:IISApplicationPoolSetting'
- $NewPool = $AppPoolSettings.CreateInstance()
- $NewPool.Name = 'W3SVC/AppPools/MyAppPool'
- $Result = $NewPool.Put()
- # Settings
- $newApplication = "MaxSys.Services"
- $poolUserName = "BRISBANEsvcMaxSysTest"
- $poolPassword = "ThisisforT3sting"
- $newVDirName = "W3SVC/1/ROOT/" + $newApplication
- $newVDirPath = "C:" + $newApplication
- $newPoolName = $newApplication + "Pool"
- #Switch the Website to .NET 2.0
- C:windowsMicrosoft.NETFrameworkv2.0.50727aspnet_regiis.exe -sn W3SVC/
- # Create Application Pool
- $appPoolSettings = [wmiclass] "rootMicrosoftIISv2:IISApplicationPoolSetting"
- $newPool = $appPoolSettings.CreateInstance()
- $newPool.Name = "W3SVC/AppPools/" + $newPoolName
- $newPool.PeriodicRestartTime = 0
- $newPool.IdleTimeout = 0
- $newPool.MaxProcesses = 2
- $newPool.WAMUsername = $poolUserName
- $newPool.WAMUserPass = $poolPassword
- $newPool.AppPoolIdentityType = 3
- $newPool.Put()
- # Do it again if it fails as there is a bug with Powershell/WMI
- if (!$?)
- {
- $newPool.Put()
- }
- # Create the virtual directory
- mkdir $newVDirPath
- $virtualDirSettings = [wmiclass] "rootMicrosoftIISv2:IIsWebVirtualDirSetting"
- $newVDir = $virtualDirSettings.CreateInstance()
- $newVDir.Name = $newVDirName
- $newVDir.Path = $newVDirPath
- $newVDir.EnableDefaultDoc = $False
- $newVDir.Put()
- # Do it a few times if it fails as there is a bug with Powershell/WMI
- if (!$?)
- {
- $newVDir.Put()
- }
- # Create the application on the virtual directory
- $vdir = Get-WmiObject -namespace "rootMicrosoftIISv2" -class "IISWebVirtualDir" -filter "Name = '$newVDirName'"
- $vdir.AppCreate3(2, $newPoolName)
- # Updated the Friendly Name of the application
- $newVDir.AppFriendlyName = $newApplication
- $newVDir.Put()
Add Comment
Please, Sign In to add comment