I am looking to use PowerShell to change IIS pool identities. I have 20 app pools and I’d like the $appPoolName part be able to cycle thorough values in a TXT file
so the credentials get applied to whatever app pool names I have in the TXT file. The Application Pool names aren’t consistent enough for me to just use a filter on the name so a TXT file is the more reliable route here.
$appPoolName
=
"AppPool_1"
$username = "DOMAIN\ACCOUNT$"
# Apply the custom identity credentials
Set-ItemProperty "IIS:\AppPools\$appPoolName" -Name processModel -Value @{
identityType = 3;
userName = $username;
}
TIA,
Dave Lum (he/him)
Systems Administrator
Work hours: Tues – Fri 5:30a – 4:30p Pacific
P: 503.546.2163
E:
lu...@ochin.org
![]()
![]()
www.ochin.org
![]()
Are you planning on using the same username for all of the app pools you want to change?
|
|
Damien Solodow |
||||||||||
--
You received this message because you are subscribed to the Google Groups "ntsysadmin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
ntsysadmin+...@googlegroups.com.
To view this discussion visit
https://groups.google.com/d/msgid/ntsysadmin/DM8PR17MB4918A37B41DD24FB160FAA72DDF52%40DM8PR17MB4918.namprd17.prod.outlook.com.
You know that “Get-ChildItem IIS:\AppPools” returns all appPools (including their name)?
(I understand that you might still just want to update certain appPools – just askin’)
From: 'Dave Lum' via ntsysadmin <ntsys...@googlegroups.com>
Sent: Thursday, July 2, 2026 11:26 AM
To: 'ntsys...@googlegroups.com' <ntsys...@googlegroups.com>
Subject: [ntsysadmin] PS script help
I am looking to use PowerShell to change IIS pool identities. I have 20 app pools and I’d like the $appPoolName part be able to cycle thorough values in a TXT file
so the credentials get applied to whatever app pool names I have in the TXT file. The Application Pool names aren’t consistent enough for me to just use a filter on the name so a TXT file is the more reliable route here.
$appPoolName
=
"AppPool_1"
--
Yes
From: ntsys...@googlegroups.com <ntsys...@googlegroups.com>
On Behalf Of Solodow, Damien
Sent: Thursday, July 2, 2026 8:32 AM
To: ntsys...@googlegroups.com
Subject: [ntsysadmin] RE: PS script help
CAUTION: This email originated from outside of OCHIN’s network
Do not click links or open attachments unless you recognize the sender and know the content is safe. If you suspect this email is phishing or a scam, use the report button in the Outlook toolbar to report it to Desktop Support.
Yep. I do that, drop to a file and them remove the pools I don’t want to change.
From: ntsys...@googlegroups.com <ntsys...@googlegroups.com>
On Behalf Of Michael B. Smith
Sent: Thursday, July 2, 2026 8:36 AM
To: ntsys...@googlegroups.com
Subject: [ntsysadmin] RE: PS script help
CAUTION: This email originated from outside of OCHIN’s network
Do not click links or open attachments unless you recognize the sender and know the content is safe. If you suspect this email is phishing or a scam, use the report button in the Outlook toolbar to report it to Desktop Support.
You know that “Get-ChildItem IIS:\AppPools” returns all appPools (including their name)?
To view this discussion visit https://groups.google.com/d/msgid/ntsysadmin/9309c861d3fd4d92914f21bf9d88ca55%40smithcons.com.
This is what I have so far, but I get Cannot find path 'IIS:\AppPools\MyAppPool1 because it does not exist. If I remove the foreach parts and run the script replacing the $inputs line with $appPoolName = "MyAppPool1", it works.
$inputs
=
Get-Content
-Path
"C:\Automate\Reports\IISAppPools.txt"
$username = "DOMAIN\ACCOUNT"
foreach ($appPoolName in $inputs) {
# Process each line here
Write-Output "Processing: $appPoolName"
Stop-WebAppPool -Name $appPoolName
Start-Sleep -Seconds 10
# Apply the custom identity credentials
Set-ItemProperty "IIS:\AppPools\$appPoolName" -Name processModel -Value @{
identityType = 3;
userName = $username;
}
Start-WebAppPool -Name $appPoolName
}
Dave
From: ntsys...@googlegroups.com <ntsys...@googlegroups.com>
On Behalf Of Michael B. Smith
Sent: Thursday, July 2, 2026 8:36 AM
To: ntsys...@googlegroups.com
Subject: [ntsysadmin] RE: PS script help
CAUTION: This email originated from outside of OCHIN’s network
Do not click links or open attachments unless you recognize the sender and know the content is safe. If you suspect this email is phishing or a scam, use the report button in the Outlook toolbar to report it to Desktop Support.
You know that “Get-ChildItem IIS:\AppPools” returns all appPools (including their name)?
To view this discussion visit https://groups.google.com/d/msgid/ntsysadmin/9309c861d3fd4d92914f21bf9d88ca55%40smithcons.com.
Does the write-output have the right app pool name, and does it successfully stop the app pool?
What I’d try is this change to the set-itemproperty line:
Set-ItemProperty "IIS:\AppPools\$($appPoolName)" -Name processModel -Value @{
|
|
Damien Solodow |
||||||||||
In the script without foreach the correct app name is displayed and the app pool does stop.
Wrapping foreach in there I get “object not found”.
My export command is
Get-ChildItem
-Path
IIS:\AppPools\
|
Select-Object
name
|
Format-Table
-AutoSize
and it lists the app pools, and the TXT file has just the name property for each pool in it.
Dave
From what you’re saying, I would think there was something wrong with the string—except that it seems to be failing for you at Set-ItemProperty while succeeding at Stop-WebAppPool. And if it works when you hard-code the variable, it can’t be what prepends it on the path for Set-ItemProperty.
So a wild guess. What do you get from the following?
$content = Get-Content -Path "C:\Automate\Reports\IISAppPools.txt"
$content[0].gettype()
--
John Wright
IT Support Specialist
![]()
1800 Old Bluegrass Avenue, Louisville, KY 40215
Please submit IT requests to Hazelwoo...@bluegrass.org
24 Hour Helpline 1.800.928.8000
CONFIDENTIALITY NOTICE: This message contains confidential information and is intended only for the individual(s) addressed in the message. If you are not the named addressee, you should not disseminate, distribute, or copy this e-mail. If you are not the intended recipient, you are notified that disclosing, distributing, or copying this e-mail is strictly prohibited.
From: 'Dave Lum' via ntsysadmin <ntsys...@googlegroups.com>
Sent: Thursday, July 2, 2026 12:03 PM
To: ntsys...@googlegroups.com
Subject: [ntsysadmin] RE: PS script help
|
EXTERNAL EMAIL - This email was sent by a person from outside your organization. Exercise caution when clicking links, opening attachments or taking further action, before validating its authenticity. |
|
Secured by Check Point |
I’m thinking it’s the data type:
(Get-ChildItem -Path IIS:\AppPools\ | Select-Object name | Format-Table -AutoSize)[0].gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False FormatStartData Microsoft.PowerShell.Commands.Internal.Format.StartData
Probably work if you export like: (Get-ChildItem -Path IIS:\AppPools\ | Select-Object name | Format-Table -AutoSize).name
--
John Wright
IT Support Specialist
![]()
1800 Old Bluegrass Avenue, Louisville, KY 40215
Please submit IT requests to Hazelwoo...@bluegrass.org
24 Hour Helpline 1.800.928.8000
CONFIDENTIALITY NOTICE: This message contains confidential information and is intended only for the individual(s) addressed in the message. If you are not the named addressee, you should not disseminate, distribute, or copy this e-mail. If you are not the intended recipient, you are notified that disclosing, distributing, or copying this e-mail is strictly prohibited.
From: 'Dave Lum' via ntsysadmin <ntsys...@googlegroups.com>
Sent: Thursday, July 2, 2026 12:27 PM
To: ntsys...@googlegroups.com
Subject: [ntsysadmin] RE: PS script help
|
EXTERNAL EMAIL - This email was sent by a person from outside your organization. Exercise caution when clicking links, opening attachments or taking further action, before validating its authenticity. |
|
Secured by Check Point |
In the script without foreach the correct app name is displayed and the app pool does stop. Wrapping foreach in there I get “object not found”.
PS C:\WINDOWS\system32> $content = Get-Content -Path "C:\Automate\Reports\IISAppPools.txt"
$content[0].gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object