Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergey-tihon/0947a36a51cef9ab355d75addfe0d867 to your computer and use it in GitHub Desktop.
Save sergey-tihon/0947a36a51cef9ab355d75addfe0d867 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