简体   繁体   English

如何验证应用程序池用户名和密码是否已更新?

[英]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.

相关问题 如何获得Window用户身份? “ User.Identity.Name”返回应用程序池标识而不是Windows用户 - How to get Window user Identity? “User.Identity.Name” returning App Pool Identity instead of Windows User 如何从 PowerShell 指定应用程序池标识用户和密码 - How to specify application pool identity user and password from PowerShell 如何一次远程更改多台服务器上的 IIS 应用程序池密码? - How to change IIS app pool password on multiple servers at once remotely? 如何在IIS中获取自定义应用程序池的标识(Windows用户)名称 - How to get identity (windows user) name for custom application pool in IIS 如何使用域Windows用户帐户作为应用程序池标识 - How to use domain windows user account as app pool identity 如何从ASP.NET中的url获取用户名和密码? - How to get user name and password from url in ASP.NET? 应用程序池回收后MVC路由丢失(标题3/3/14更新) - MVC routes lost after app pool recycle (updated title 3/3/14) IIS使我与应用程序池用户混淆 - IIS confuses me with app pool user 使用应用程序池标识和正在运行的用户 - Use App Pool Identity and User that running process IIS模拟返回应用程序池用户 - IIS impersonation returns app pool user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM