Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active July 15, 2024 09:25
Show Gist options
  • Save dfinke/7773004 to your computer and use it in GitHub Desktop.
Save dfinke/7773004 to your computer and use it in GitHub Desktop.
Developers use GUIDs in there code. This PowerShell function takes a path, looks for C# files and searches (greps) for a GUID pattern. `Find-GuidUsage c:\<Your Code>`
function Find-GuidUsage {
param(
[Parameter(Mandatory=$true)]
$path,
$filter="*.cs"
)
$GuidPattern = "({|\()?[A-Fa-f0-9]{8}-([A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}(}|\))?"
dir $path -Recurse $filter |
Select-String $GuidPattern
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment