PowerShell script to change Password for App pool and manage account in SharePoint Onprem server


Hari Rama Krishnan
Technology Specialist
Published On :   27 May 2018
Visit Count
Today :  3    Total :   948




In development machine if we install the SharePoint on premise(2010 or 2013 SharePoint server) with User or our Id , due to policy if we change our password for installation ID, then We will  face issue on access SharePoint site due to password , the work around solution for this is once the installation id password, changed then   the app pool and Manage account password also need to be changed, instead changing manually by going to IIS and SharePoint Central administration we can execute the below script on SharePoint server to change the password

App Pool Password change

 Add-PSSnapin "Microsoft.SharePoint.PowerShell"
 
 Import-Module WebAdministration
 $applicationPools = Get-ChildItem IIS:\AppPools | where { $_.processModel.userName -eq "domain\username" }
  
 foreach($pool in $applicationPools)
 {
     $pool.processModel.userName = "domain\username"
     $pool.processModel.password = "password"
     $pool.processModel.identityType = 3
     $pool | Set-Item
 }
  
 Write-Host "Application pool passwords updated..." -ForegroundColor Magenta 
 Write-Host "" 
 Read-Host -Prompt "Press Enter to exit"
 

Managed Account Password change

 $m = Get-SPManagedAccount -Identity “domain\username”
  
 Set-SPManagedAccount -Identity $m  -ExistingPassword (ConvertTo-SecureString "Password" -AsPlainText -force) –confirm
 


Hope the handy script helps you to change managed and app pool account password and save few hours of effort.


Happy Coding,

Hariramakrishnan Vasuthevan

Categories