如何从PowerShell指定应用程序池标识用户和密码 [英] How to specify application pool identity user and password from PowerShell

查看:649
本文介绍了如何从PowerShell指定应用程序池标识用户和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用应用程序池标识自动设置Web应用程序和配置IIS时遇到了很多困难。我在用PowerShell编写的Web应用程序部署脚本中执行此操作。我的要求是我需要我的PowerShell脚本将应用程序池标识用户设置为特定的服务帐户mydomain\svcuser和密码。以下是示例代码:

I have been having lots of difficulty automating the setup of a Web application and configuring IIS appropriately with the Application Pool Identity. I am doing this in a Web application deployment script written in PowerShell. My requirement is that I need my PowerShell script to set the application pool identity user to a specific service account mydomain\svcuser and password. Here is the sample code:

$pool = New-Item "IIS:\AppPools\MyAppPool" -Force
$svcuser = "mydomain\svcuser"
$pool.processModel.userName = $svcuser
$password = "somepassword"
$pool.processModel.password = $password
$pool.processModel.identityType = 3
$pool | Set-Item -ErrorAction Stop

当我运行它时,所有出现到工作正常 - 没有错误被抛出,应用程序标识用户名出现在IIS中 - 但由于某种原因,密码没有正确设置,如果有的话。由于它是一个密码,我无法验证它是否已设置,但我可以断定,如果它是,它没有设置正确。在我手动进入并在IIS中输入密码之前,它不会对生成的应用程序池用户进行身份验证。因此,应用程序在部署到Web服务器后失败并需要手动干预。

When I run this, everything appears to work correctly--no errors are thrown and the application identity user name appears in IIS--but for some reason the password does not get set correctly, if at all. Since it is a password I cannot verify whether it has been set, but I can conclude that it if it is, it is not set correctly. It will not authenticate the resulting application pool user until I manually go in and enter the password in IIS. As a result the application fails after being deployed to the Web server and requires manual intervention.

我在这里遗漏了什么吗?

Am I missing something here?

推荐答案

您可以按如下方式执行此操作:

You would do this as follows:

Import-Module WebAdministration
Set-ItemProperty IIS:\AppPools\app-pool-name -name processModel -value @{userName="user_name";password="password";identitytype=3}

请参阅此文档以获取解释,并在以下位置运行应用程序池的用户类型的缩进类型数字的引用: http://www.iis.net/configreference/system.applicationhost/applicationpools/添加/进程模型

See this document here for an explanation, and a reference of the indentity type numeric for the user type you will run the app pool under: http://www.iis.net/configreference/system.applicationhost/applicationpools/add/processmodel

这篇关于如何从PowerShell指定应用程序池标识用户和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆