Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you change an IIS Site's App Pool with the Powershell Web Admin Commandlets

Tags:

powershell

iis

The following code demonstrates what I thought might work, but it doesn't change the app pool - it remains set at its current value (even though the $site object does update):

import-module WebAdministration  $site = get-item "IIS:\Sites\Project" $site.ApplicationPool = "ProjectAppPool" $site | set-item 

If you create the site with New-WebSite specifying the -ApplicationPool parameter, it creates as expected. What Powershell IIS web command must I use to change an existing site's app pool to something different?

like image 358
ZeroBugBounce Avatar asked Jan 07 '11 20:01

ZeroBugBounce


People also ask

How do I check IIS application pool status in PowerShell?

To get the IIS application pool names using PowerShell, you need to use the IIS PSDrive but for that, we need the IIS PowerShell module WebAdministration or IISAdministration on the server we are running the command. If the WebAdministration module is already installed, use the below command to import the module.

Which PowerShell command is used to create a new Web application?

The New-WebApplication cmdlet creates an Internet Information Services (IIS) web application.


1 Answers

ApplicationPool is a property on the web site in the IIS: drive. Set it like so:

#site level Set-ItemProperty 'IIS:\Sites\Default Web Site' applicationPool ProjectAppPool  #app level Set-ItemProperty 'IIS:\Sites\Default Web Site\AppName' applicationPool ProjectAppPool 

If you have the PowerShell Community Extensions installed, you can use the Show-Tree command to explore these drives e.g.:

Show-Tree IIS:\Sites -ShowProperty -Depth 1 
like image 59
Keith Hill Avatar answered Oct 13 '22 23:10

Keith Hill