Guest User

Untitled

a guest
Jan 29th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. param(
  2. [Parameter(Mandatory=$true)][string]$Username,
  3. [Parameter(Mandatory=$true)][string]$Password
  4. )
  5.  
  6. Import-Module WebAdministration
  7. $appPools = Get-ChildItem IIS:AppPools | where { $_.processModel.userName -eq $Username }
  8.  
  9. if ($appPools.Count -eq 0)
  10. {
  11. Write-Host "No AppPools found with username:" $Username -ForegroundColor Red
  12. }
  13. else
  14. {
  15. Write-Host "Found" $appPools.Count "AppPools to update..." -ForegroundColor DarkGreen
  16.  
  17. foreach ($pool in $appPools)
  18. {
  19. $pool.processModel.userName = $Username
  20. $pool.processModel.password = $Password
  21. $pool.processModel.identityType = 3
  22. $pool | Set-Item
  23. }
  24.  
  25. Write-Host "Restarting IIS..." -ForegroundColor DarkGreen
  26. iisreset
  27. Write-Host "AppPool passwords updated successfully" -ForegroundColor DarkGreen
  28. }
Add Comment
Please, Sign In to add comment