如何在PowerShell中使用Web管理模块设置应用程序池的应用程序标识? [英] How to set application identity of an application pool using web administration module in powershell?

查看:211
本文介绍了如何在PowerShell中使用Web管理模块设置应用程序池的应用程序标识?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PowerShell自动配置IIS中的网站。
我有以下代码为我创建一个Web应用程序池

I am using powershell to automate configuring websites in my IIS. I have the following code that creates a web application pool for me

#Creating a new Application Pool
New-WebAppPool "NewAppPool"

如何设置应用程序池标识到我的脚本中的网络服务?

请注意:我的系统上没有IIS驱动器。因此命令在路径中提到IIS,如下所示:

Please note : There is no IIS Drive on my system. And hence commands which have IIS mentioned in the path like the following fail :

Set-ItemProperty IIS:\AppPools\NewAppPool -name processModel.identityType -value 2


推荐答案

导入时Web管理模块, PowerShell 构建一个名为 IIS 的驱动器。此驱动器允许您像管理文件系统一样管理 IIS ,只需使用 IIS:而不是 C:来表示驱动器。

When you import the WebAdministration module, PowerShell builds a drive called 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.

你可以像这样创建一个游泳池:

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

因此,要使用以下命令,您必须使用WebAdministration模块:

So for using the below command you have to use the WebAdministration module:

Set-ItemProperty IIS:\AppPools\NewAppPool -name processModel.identityType -value 2

希望有所帮助。

这篇关于如何在PowerShell中使用Web管理模块设置应用程序池的应用程序标识?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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