…if you remove the trailing spaces from the lines in the TXT file it magically works…
Dave
From: 'Dave Lum' via ntsysadmin <ntsys...@googlegroups.com>
Sent: Thursday, July 2, 2026 9:35 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.
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
From: ntsys...@googlegroups.com <ntsys...@googlegroups.com>
On Behalf Of Wright, John M
Sent: Thursday, July 2, 2026 9:31 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.
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 |
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)?
(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"
$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
![]()
Attention: Information contained in this message and or attachments is intended only for the recipient(s) named above and may contain confidential and or privileged material that is protected under State or Federal law. If you are not the intended recipient, any disclosure, copying, distribution or action taken on it is prohibited. If you believe you have received this email in error, please contact the sender with a copy to compl...@ochin.org, delete this email and destroy all copies.
--
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 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/9309c861d3fd4d92914f21bf9d88ca55%40smithcons.com.
Attention: Information contained in this message and or attachments is intended only for the recipient(s) named above and may contain confidential and or privileged material that is protected under State or Federal law. If you are not the intended recipient, any disclosure, copying, distribution or action taken on it is prohibited. If you believe you have received this email in error, please contact the sender with a copy to compl...@ochin.org, delete this email and destroy all copies.
--
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/DM8PR17MB491841E646256A218C67B9A6DDF52%40DM8PR17MB4918.namprd17.prod.outlook.com.
--
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/SN7PR12MB671447202E771C737DFA40AE91F52%40SN7PR12MB6714.namprd12.prod.outlook.com.
Attention: Information contained in this message and or attachments is intended only for the recipient(s) named above and may contain confidential and or privileged material that is protected under State or Federal law. If you are not the intended recipient, any disclosure, copying, distribution or action taken on it is prohibited. If you believe you have received this email in error, please contact the sender with a copy to compl...@ochin.org, delete this email and destroy all copies.
--
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/DM8PR17MB4918072A2BEA662DF905C481DDF52%40DM8PR17MB4918.namprd17.prod.outlook.com.
Trailing whitespace is evil. One day Powershell will get updated with a -RemoveInvisibleThings parameter.
Most likely caused by the format-table -autosize 😊
|
|
Damien Solodow |
||||||||||
From: 'Dave Lum' via ntsysadmin <ntsys...@googlegroups.com>
Sent: Thursday, July 2, 2026 12:39 PM
To: 'ntsys...@googlegroups.com' <ntsys...@googlegroups.com>
Subject: [ntsysadmin] RE: PS script help - SOLVED. ID10T error
…if you remove the trailing spaces from the lines in the TXT file it magically works…
Or use the .trim() method on the strings. 😊
|
|
Damien Solodow |
||||||||||
Yep. It’s how I am really good and fine-tuning things. My coworkers like many of my processes but mainly it’s really just years of “I did stupid shit an learned from it. Sometimes”
“Hey, why do your PS scripts that send email all have the name of the script and the server name that sent them?”
“Oh, no reason…”
Dave