Scripting help with non 8.3 format directory

I have the following ps script that just updates a single line within a config file. (line 102) The script I use works fine for 8.3 format file paths but now I need help to make sure it works for LFN paths. Not sure how to address the path.


I wish to use the following path –


C:Program Files (x86)Microsoft Dynamics CRMClientreswebweb.config


Heres my script:


$content = Get-Content c:testweb.config

$content |


if ($.ReadCount -ge 102 -and $.ReadCount -le 102){ $_ -replace ‘w+’,’add key=”ReportViewerMessages” value=”Microsoft.Crm.Web.Reporting.CrmReportViewerMessages, Microsoft.Crm.Application.Outlook.Pages, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″‘


else {

$_ }

} |

Set-Content C:testweb.config


Thanks in advance if you can help. 🙂


PS – if I use inverted commas in path ” “, the loop within the script seems to replicate line many times on same line.

submitted by /u/gstandard00
[link] [comments]

Leave a Reply