Avatar of E=mc2
E=mc2Flag for Canada

asked on 

Replace string of text using Powershell or another script

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>

Open in new window


With this:

<script>
$(document).ready(function() {
    $('.enhancedhtml-dynamic-table').dataTable({
        "aLengthMenu": [[25, 50, 75, -1], [25, 50, 75, "All"]],
        "iDisplayLength": 25
    });
} );
</script>

Open in new window


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

Open in new window

Thanks in advance for your assistance. 
PowershellWindows BatchVB ScriptHTMLScripting Languages

Avatar of undefined
Last Comment
Kimputer
ASKER CERTIFIED SOLUTION
Avatar of Kimputer
Kimputer

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
HTML
HTML

HTML (HyperText Markup Language) is the main markup language for creating web pages and other information to be displayed in a web browser, providing both the structure and content for what is sent from a web server through the use of tags. The current implementation of the HTML specification is HTML5.

62K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo