PowerShell を使用して IIS にアプリケーション プールを作成しようとしています。Web を検索した後、次のテスト スクリプトを作成しました。
Import-Module WebAdministration
$siteName = "TestAppPool"
$userAccountName = "Domain\UserName"
$userAccountPassword = "MyPassword"
if(!(Test-Path ("IIS:\AppPools\" + $siteName)))
{
$appPool = New-Item ("IIS:\AppPools\" + $siteName)
#Display Default AppPool Settings
"AppPool = " + $appPool
"UserName = " + $appPool.processModel.userName
"Password = " + $appPool.processModel.password
"Runtime = " + $appPool.managedRuntimeVersion
$appPool.processModel.userName = $userAccountName
$appPool.processModel.password = $userAccountPassword
$appPool.managedRuntimeVersion = "v4.0"
$appPool | Set-Item
#Display Updated AppPool Settings
"AppPool = " +$appPool
"UserName = " + $appPool.processModel.userName
"Password = " + $appPool.processModel.password
"Runtime = " + $appPool.managedRuntimeVersion
}
スクリプトを実行すると、ユーザー名とパスワードが設定した値に更新されません。
2 つの印刷ブロックの結果を次に示します。
#Display Default AppPool Settings
AppPool = Microsoft.IIs.PowerShell.Framework.ConfigurationElement
UserName =
Password =
Runtime = v2.0
#Display Updated AppPool Settings
AppPool = Microsoft.IIs.PowerShell.Framework.ConfigurationElement
UserName =
Password =
Runtime = v2.0
IIS を見ると、アプリケーション プールは .Net Framework が更新されたことを示していますが、ID はまだ ApplicationPoolIdentity に設定されています。ドメイン\ユーザー名である必要があります。
私はマシンの管理者であり、PowerShell を管理者モードで実行しています。これを機能させるために何が欠けているかについてのアイデアはありますか?