troubleshooting Question

Replace string of text using Powershell or another script

Avatar of E=mc2
E=mc2 asked on
HTMLScripting LanguagesWindows BatchVB ScriptPowershell
1 Comment1 Solution11 ViewsLast Modified:
In an .html file, I would like to replace this string of text:

<script type="text/javascript">$(document).ready(function () {$('.enhancedhtml-dynamic-table').dataTable();} );</script>

With this:

$(document).ready(function() {
        "aLengthMenu": [[25, 50, 75, -1], [25, 50, 75, "All"]],
        "iDisplayLength": 25
} );

How can I add these instructions within an existing Powershell script?

Current I use this method in Powershell but it is not working:

$oldcontent = '... first string here'
$newcontent = '... second string of text here'
$writeto = '.\Report.html'

((Get-Content -path $writeto -Raw) -replace $oldcontent,$newcontent) | Set-Content -Path $writeto
Thanks in advance for your assistance. 
KimputerIT Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros