简体   繁体   English

如何在Powershell中使用Web管理模块设置应用程序池的应用程序身份?

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

相关问题 如何使用PowerShell和Web管理模块检查IIS中是否存在应用程序池? - How to check whether an application pool exists or not in IIS using powershell and web administration module? 如何通过PowerShell设置IIS网站(不是应用程序池)标识字段(用户名和密码)? - How can I set up IIS website (not Application Pool) identity fields (username & password) via PowerShell? 使用PowerShell脚本时IIS应用程序池回收身份 - IIS Application Pool recycling Identity when using PowerShell script 如何从 PowerShell 指定应用程序池标识用户和密码 - How to specify application pool identity user and password from PowerShell 使用Powershell的应用程序池标识预定义/可配置开关 - Application Pool Identity Predefined/Configurable switch with Powershell 在Web应用程序中通过C#调用Powershell - 应用程序池标识问题 - Invoking Powershell via C# in a web application - issues with app pool identity 如何使用 PowerShell 远程检查 Web 应用程序池的状态? - How to remotely check the status of a web application pool with PowerShell? 如何在 IIS 管理器中使用 PowerShell 或 appcmd 在 Compression 中设置应用程序池磁盘空间限制? - How do I set the application pool disk space limit in IIS Manager in Compression using PowerShell or appcmd? IIS PowerShell应用程序池设置为“NetworkService”帐户 - IIS PowerShell Application Pool set as 'NetworkService' Account 如何使用Powershell为应用程序池计算处理器相似性掩码? - How to calculate Processor Affinity Mask for an Application Pool using Powershell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM