Good afternoon all.
I'm fairly new to powershell, and am having a devil of a time trying to sort this little thing out. I'm sure it's super easy for people who deal with Powershell on a daily basis. So, what I am trying to do, is search for every computer in our domain with a certain naming convention ( wPROD, and wDEV), and then on each of those computers, replace a specific line of text in an .INI file while keeping the rest of the .INI file intact. Here is what my script is looking like right at this moment, but it's just not working out well for me, and any assistance would be more than greatly appreciated.
#Importing AD Module to search for computers Import-Module -NameActiveDirectory $computer =Get-ADComputer-filter"name -Like 'wprod*' -or name -Like 'wdev*'"|Format-tablename #REPLACE SECTION $original_file ='"\\$computer\C$\Program Files\nscp\nsc.ini"' $destination_file ='"\\$computer\C$\Program Files\nscp\nsc.ini"' Get-Content $original_file|Foreach-Object {$_-replace"checkMem MaxWarn=80% MaxCrit=90% ShowAll Type=Page","checkMem MaxWarn=80% MaxCrit=90% ShowAll Type=Physical"} |Set-Content$destination_file