【问题标题】:IIS Application Pool recycling Identity when using PowerShell script使用 PowerShell 脚本时的 IIS 应用程序池回收标识
【发布时间】:2015-03-30 11:41:53
【问题描述】:

我今天尝试使用 PowerShell 开发安装 WCF Web 服务。我正在使用在 Windows Server 2012 和 IIS 8.5.96 上执行的 PowerShell 脚本。

起初我手动设置了服务,只是为了确保一切正常,并且我需要在脚本中包含新的设置。然后我删除了应用程序池、网站和文件夹目录。

我已经运行了该脚本,并且它可以工作,但是每次运行它都会将应用程序池设置为我在手动创建服务时使用的Identity

以下是我目前拥有的脚本。您可以看到我没有在任何地方指定应用程序池标识,所以我认为它必须存储在计算机上的某个位置.. 但是我没有找到它(我已经搜索了两个 @ 987654322@ 和 D 驱动器,此服务器上仅有的两个分区)。

有什么想法/想法吗? #加载IIS模块 导入模块 WebAdministration Add-WindowsFeature Web-Scripting-Tools

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

【问题讨论】:

  • 您的问题是什么?默认情况下,身份是 ApplicationPoolIdentity 或“IIS APPPOOL\NameOfThePool”,只要您不更改 appPool 名称并且不更改身份,否则它将使用相同的虚拟帐户。

标签: wcf powershell iis windows-server-2012 windows-server-2012-r2


【解决方案1】:

我不确定是什么导致 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?How+to+configure+application+pool+identity+from+powershell+

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-10
    • 2015-04-19
    • 1970-01-01
    • 2011-09-20
    • 1970-01-01
    • 1970-01-01
    • 2011-10-08
    • 2017-12-15
    相关资源
    最近更新 更多