Monday, July 27, 2015

Updating all guids in a file using Powershell

I'm getting to really like powershell. Today I needed to generate a whole lot of guids in multiple build files and was able to do what I needed with a single line:

(Get-Content 'filename') | ForEach-Object { $_ -replace "[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}", [guid]::NewGuid() } | Set-Content 'filename'

No comments: