Skip to content

Instantly share code, notes, and snippets.

@manualbashing
Last active June 12, 2023 14:12
Show Gist options
  • Save manualbashing/9cf1c8c6369f9498d80efd23ee45bd7d to your computer and use it in GitHub Desktop.
Save manualbashing/9cf1c8c6369f9498d80efd23ee45bd7d to your computer and use it in GitHub Desktop.
Create deterministric GUID from string
function Get-DeterministricGuid {
param
(
[String] $InputObject
)
$Hash = New-Object System.Text.StringBuilder
$([System.Security.Cryptography.HashAlgorithm]::Create('MD5')).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($InputObject)) |
ForEach-Object {
$null = $Hash.Append($_.ToString("x2"))
}
$hashString = $Hash.ToString().ToUpper()
return [Guid]::New($hashString)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment