Skip to content

Instantly share code, notes, and snippets.

@carstengehling
Created August 24, 2023 18:21
Show Gist options
  • Save carstengehling/73d874dfb9f10c141ba60fb58a680a9d to your computer and use it in GitHub Desktop.
Save carstengehling/73d874dfb9f10c141ba60fb58a680a9d to your computer and use it in GitHub Desktop.
Powershell snippets
###############################################################################
# Search/replace text in files recursively
$utf8 = New-Object System.Text.UTF8Encoding $True
Get-ChildItem . *.xaml -recurse |
Foreach-Object {
$content = [System.IO.File]::ReadAllText($_.FullName)
if ($content.Contains('{DynamicResource '))
{
$content = $content.Replace('{DynamicResource ','{StaticResource ')
[IO.File]::WriteAllText($_.FullName, $content, $utf8)
}
}
###############################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment