Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param(
- [Parameter(Mandatory=$true)][string]$Username,
- [Parameter(Mandatory=$true)][string]$Password
- )
- Import-Module WebAdministration
- $appPools = Get-ChildItem IIS:AppPools | where { $_.processModel.userName -eq $Username }
- if ($appPools.Count -eq 0)
- {
- Write-Host "No AppPools found with username:" $Username -ForegroundColor Red
- }
- else
- {
- Write-Host "Found" $appPools.Count "AppPools to update..." -ForegroundColor DarkGreen
- foreach ($pool in $appPools)
- {
- $pool.processModel.userName = $Username
- $pool.processModel.password = $Password
- $pool.processModel.identityType = 3
- $pool | Set-Item
- }
- Write-Host "Restarting IIS..." -ForegroundColor DarkGreen
- iisreset
- Write-Host "AppPool passwords updated successfully" -ForegroundColor DarkGreen
- }
Add Comment
Please, Sign In to add comment