2008-11-04 26 views
6

kullanarak IIS 6.0 Uygulama Havuzu Oluşturma IIS 6.0'da bir PowerShell komut dosyası kullanarak bir Uygulama Havuzu nasıl oluşturabilirim? Bu defa ile geldi budurBir Powershell

...

$appPool = [wmiclass] "root\MicrosoftIISv2:IIsApplicationPool" 

Teşekkür

cevap

6

Bu en bariz bir süreç değildir, ama burada benim için çalıştı budur ..

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

Put() çağrısı ile bir hatayla karşılaşabilirsiniz, ancak bunu ikinci (veya üçüncü) bir kez çağırmak işe yaramalıdır. Bunun nedeni, PowerShell V1 ve WMI ile ilgili bir sorundur.

+0

Teşekkür ederim, çok iyi çalışıyor. Ben bunu denedim, ama bu put hatası ile ertelendi. –

+0

Sizin için çalıştığıma sevindim. Bu hata bir tür dikkat dağıtıcı, ama bu sadece PowerShell’in V1’idir. –

7

Geldiğim senaryoyu paylaşabilirim. Teşekkürler Steven ve Leon'a gidiyor.

# Settings 
$newApplication = "MaxSys.Services" 
$poolUserName = "BRISBANE\svcMaxSysTest" 
$poolPassword = "ThisisforT3sting" 

$newVDirName = "W3SVC/1/ROOT/" + $newApplication 
$newVDirPath = "C:\" + $newApplication 
$newPoolName = $newApplication + "Pool" 

#Switch the Website to .NET 2.0 
C:\windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -sn W3SVC/ 

# Create Application Pool 
$appPoolSettings = [wmiclass] "root\MicrosoftIISv2: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] "root\MicrosoftIISv2: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 "root\MicrosoftIISv2" -class "IISWebVirtualDir" -filter "Name = '$newVDirName'" 
$vdir.AppCreate3(2, $newPoolName) 

# Updated the Friendly Name of the application 
$newVDir.AppFriendlyName = $newApplication 
$newVDir.Put() 
+0

@robert wagner - Hata işleminizi DO olarak değiştireceğim {$ newVDir.Put()} WHILE (! $?) Sonra, ilk Put() 'a sahip olmanız gerekmeyecektir. Do/while döngüsü, hata oluşuncaya kadar sunumu gerçekleştirmeye devam edecektir. Sadece bir öneri. –

+0

Sonsuz bir döngüde sıkışabilir, ama bu bir düşünce. –

+0

her zaman küçük bir sayaca sahip olabilirsiniz, sadece maksimum sayıda tekrar deneme yapabilirsiniz. – jrista

0

Her şey yolunda! Kodu değiştirdim, böylece ilk hatadan sonra $ newPool.Put() komutuna açık bir çağrı var. Yardım ettiğin için teşekkür ederim!