We have a program that creates email signatures and stores them in a deployment folder that is then saved to the users local folder when they log in. However when the employee is not assigned to an office, the comma separator for City/State still come along for the ride as shown in this example:
Problem is the program source code cannot be found. Long term I will rewrite it. Short term I need a powershell script that will run every night to remove the line containing the commas. Found the following solution here on Stackoverflow:
Get-ChildItem C:\temp\emailsigs -Filter *.htm | Foreach-Object{
(Get-Content $_.FullName) |
Foreach-Object {$_ -replace " , , <br />", ""} |
Set-Content $_.FullName
}
This actually works pretty well. But I notice that each signature HTM file (over 1100) is getting the timestamp update even when only 2 email signatures need to have the empty comma line removed. Is there a more efficient way to first check if the file contains the offending commas to then replace and skip over the majority?