Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created January 3, 2015 16:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wpsmith/a04f47cf4fa514a0a46b to your computer and use it in GitHub Desktop.
Save wpsmith/a04f47cf4fa514a0a46b to your computer and use it in GitHub Desktop.
asnp *SharePoint* -ErrorAction SilentlyContinue
// URL of the Web App to change the Application Pool of.
$WebAppURL = "http://WebApp"
// name of the name Application Pool that will be created.
$NewAppPoolName = "NewAppPool"
//the user account that the Application Pool will run under the context of.
$NewAppPoolUserName = "contoso\apppool"
/* All done. Go time. */
$Farm = Get-SPFarm
$Service = $Farm.Services | where {$_.TypeName -eq "Microsoft SharePoint Foundation Web Application"}
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$NewAppPool = New-Object Microsoft.SharePoint.Administration.SPApplicationPool($NewAppPoolName,$Service)
$NewAppPool.CurrentIdentityType = "SpecificUser"
$NewAppPool.Username = $NewAppPoolUserName
$NewAppPool.SetPassword($Password)
$NewAppPool.Provision()
$NewAppPool.Update($true)
$NewAppPool = $Service.ApplicationPools[$NewAppPoolName]
$WebApp = Get-SPWebApplication $WebAppURL
$WAAppPool = $WebApp.ApplicationPool = $NewAppPool
$WebApp.Update()
$WebApp.ProvisionGlobally()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment