Creating an IIS 6.0 Application Pool using Powershell

后端 未结 3 1956
忘掉有多难
忘掉有多难 2021-02-04 19:24

How do I create an Application Pool on IIS 6.0 using a PowerShell script?

This is what I have come up with so far ...

$appPool = [wmiclass] \"root\\Micro         


        
3条回答
  •  自闭症患者
    2021-02-04 19:48

    It isn't the most obvious process, but here is what worked for me..

    $AppPoolSettings = [wmiclass]'root\MicrosoftIISv2:IISApplicationPoolSetting'
    $NewPool = $AppPoolSettings.CreateInstance()
    $NewPool.Name = 'W3SVC/AppPools/MyAppPool'
    $Result = $NewPool.Put()
    

    You might get an error with the call to Put(), but calling it a second (or third) time should make it work. This is due to an issue with PowerShell V1 and WMI.

提交回复
热议问题