簡體   English   中英

使用PowerShell腳本時IIS應用程序池回收身份

[英]IIS Application Pool recycling Identity when using PowerShell script

今天,我正在嘗試通過WCF Web服務的開發安裝來使用PowerShell。 我正在使用在Windows Server 2012和IIS 8.5.96上執行的PowerShell腳本。

首先,我手動設置服務,只是為了確保一切正常,然后重新添加需要在腳本中包含的設置。 然后,我刪除了應用程序池,網站和文件夾目錄。

我已經運行了腳本,並且可以運行,但是每次運行時,它將使用我手動創建服務時使用的Identity來設置應用程序池。

下面是到目前為止的腳本。 您可以看到我沒有在任何地方指定應用程序池標識,因此我認為它必須存儲在計算機上的某個位置。.但是我沒有運氣找到它(我已經在兩個C上都進行了搜索和D驅動器,這是該服務器上僅有的兩個分區)。

有什么想法/想法嗎? #load IIS模塊Import-Module WebAdministration Add-WindowsFeature Web腳本工具

#variables
$okeeffename = "OKeeffe"
$domain = "InsideServices.dev.com"
$okeeffeapppoolname = "OKeeffeApplicationPool"
$okeeffeiis = "IIS:\AppPools\$okeeffeapppoolname"
$logpath = "D:\SystemLogFiles\LogFiles"
$domainpath = "d:\webcontent\$domain"
$okeeffedirectory = "d:\webcontent\$domain\$okeeffename"
$okeeffestagingpath = "\\prdhilfs02\install\Monet\ServerUpgrade\DEVHILWB119\OKeeffe"

#create webcontent and application folders
Write-Host "Creating directories" -ForegroundColor Yellow
New-Item -Path $domainpath -type directory -ErrorAction Stop
New-Item -Path $okeeffedirectory -type directory -ErrorAction Stop

#create log folder, if it doesn't exist
if(-not (Test-Path -path $logpath))
{   
    New-Item -Path $logpath -type directory 
}

#create app pool
if(-not (Test-Path -path $okeeffeiis))
{
    #Write-Host "Creating app pool: $okeeffeapppoolname" -ForegroundColor Yellow
    New-WebAppPool $okeeffeapppoolname -force -ErrorAction Stop
    set runtime version
    Set-ItemProperty "IIS:\AppPools\$okeeffeapppoolname" managedRuntimeVersion v4.0
}

我不太確定是什么導致使用以前的身份創建AppPool,但是也許您可以嘗試立即在New-WebAppPool返回的ConfigurationElement對象上設置一些屬性:

# Get reference to ConfigurationElement for AppPool...
$pool = New-WebAppPool $okeeffeapppoolname -force -ErrorAction Stop

$pool.processModel.identityType = "SpecificUser"
$pool.processModel.username = 'domain\username'
$pool.processModel.password = 'password'

$pool | Set-Item

參考: http : //forums.iis.net/t/1171615.aspx?如何+配置+應用程序+池+身份+自+ powershell +

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM