[英]How to set application identity of an application pool using web administration module in powershell?
I am using powershell to automate configuring websites in my IIS. 我正在使用Powershell在IIS中自动配置网站。 I have the following code that creates a web application pool for me
我有以下代码为我创建了一个Web应用程序池
#Creating a new Application Pool
New-WebAppPool "NewAppPool"
How do I go about setting the application pool identity to "Network Service" from my script ? 如何从脚本中将应用程序池标识设置为“网络服务”?
Please note : There is no IIS Drive on my system. 请注意:我的系统上没有IIS驱动器。 And hence commands which have IIS mentioned in the path like the following fail :
因此,路径中提到的具有IIS的命令如下所示将失败:
Set-ItemProperty IIS:\AppPools\NewAppPool -name processModel.identityType -value 2
When you import the WebAdministration module, PowerShell builds a drive called IIS . 导入WebAdministration模块时, PowerShell会构建一个名为IIS的驱动器。 This drive allows you to manage IIS just like you would via the file system by simply using IIS: instead of C: to represent the drive.
该驱动器使您可以像通过文件系统一样管理IIS ,只需使用IIS:而不是C:来代表驱动器。
You can create a Pool like: 您可以创建一个池,如下所示:
New-Item IIS:\AppPools\$AppPool
$NewPool = Get-Item IIS:\AppPools\$AppPool
$NewPool.ProcessModel.Username = "$Username"
$NewPool.ProcessModel.Password = "$Password"
$NewPool.ProcessModel.IdentityType = 2
$NewPool | Set-Item
So for using the below command you have to use the WebAdministration module: 因此,对于使用以下命令,您必须使用WebAdministration模块:
Set-ItemProperty IIS:\AppPools\NewAppPool -name processModel.identityType -value 2
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.