[英]How to verify that app pool user name and password is updated?
I have written a powershell script to update username and password of apppool using "webadministration" snapin. 我已经编写了一个Powershell脚本来使用“ webadministration”管理单元更新apppool的用户名和密码。
Import-Or-Snapin -Module "Webadministration"
Function Change-AppPoolIdentity {
Param (
$AppPool,
$OldUserName,
$NewUserName,
$Password
)
If (Test-Path $AppPool)
{
LogWrite "Function :Change-AppPoolIdentity"
$MyAppPool = Get-Item $AppPool
If ($($MyAppPool.processModel.userName) -eq $OldUserName) {
$MyAppPool.Stop()
LogWrite "Trying to change App pool user name and password"
$MyAppPool | Set-ItemProperty -Name "processModel.username" -Value $NewUserName
$MyAppPool | Set-ItemProperty -Name "processModel.password" -Value $Password
$MyAppPool.Start()
}
Else {
LogWrite "Apppool $AppPool does not run using $OldUserName"
}
}
Else {
LogWrite "Apppool $AppPool not available "
}
}
After executing the script i was trying to access the site it did not show up. 执行脚本后,我试图访问该站点,但未显示。 When we did manually set the password it worked.
当我们手动设置密码后,它就可以工作了。 We suspect that password is not updated correctly.
我们怀疑密码未正确更新。
How to ensure that app pool password got changed? 如何确保应用程序池密码已更改? After Set-item ,is it possible to add a condition to verify that?
在Set-item之后,是否可以添加条件进行验证?
I am relatively new to the IIS powershell provider, but I believe you may need to call set-item in order to save the configuration changes to the application pool. 我是IIS Powershell提供程序的新手,但我相信您可能需要调用set-item才能将配置更改保存到应用程序池中。
To test, get the application pool item, print out the processModel password value to see the original value (surprised me when I saw this), then update it, then be sure to call set-item to update IIS. 要进行测试,请获取应用程序池项,打印出processModel密码值以查看原始值(当我看到此值时感到惊讶),然后对其进行更新,然后确保调用set-item来更新IIS。
eg 例如
$pool = IIS:\apppools\myapppool
$pool.processModel.password
$pool.processModel.password = $new_password
# doens't take effect until this
#
$pool | set-item
# should show updated value
#
$pool.processModel.password
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.