Created
November 24, 2015 14:32
-
-
Save michaellwest/0b607d7ae89b984fc4d1 to your computer and use it in GitHub Desktop.
Replaces all instances of the Google Analytics click event with an empty string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$path = "master:\content\" | |
$items = Get-ChildItem -Path $path -Recurse | |
$fields = @("Ads","Body","Carousel","HtmlText","Left Body","Location Body","Mid Body","Quick Links and News","Search Location") | |
$updateCounts = @{} | |
$fields | ForEach-Object { $updateCounts[$_] = 0 } | |
foreach($item in $items) { | |
Write-Host "Processing $($item.Id) : $($item.Name)" | |
foreach($field in $fields) { | |
if($item.$field) { | |
Write-Host "Updating $($field)" | |
$fieldValue = $item.$field -replace ' onclick="_gaq.*\);"','' | |
$updateCounts[$field] += 1 | |
$item.$field = $fieldValue | |
} | |
} | |
} | |
$updateCounts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment