Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function PromptGuid
- {
- $guid = New-Guid
- Write-Host -NoNewline "Choose a format to copy (r to regen): "
- $op_pos = $host.UI.RawUI.CursorPosition
- Write-Host
- Write-Host " (enter) : $($guid.ToString())"
- Write-Host " B : $($guid.ToString('B'))"
- Write-Host " N : $($guid.ToString('N'))"
- Write-Host " X : $($guid.ToString('X'))"
- $end_pos = $host.UI.RawUI.CursorPosition
- $host.UI.RawUI.CursorPosition = $op_pos
- $option = ($host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")).Character
- $host.UI.RawUI.CursorPosition = $end_pos
- if ($option -ieq 'r')
- {
- Clear-Host
- return $false
- }
- $isEnter = ([int]$option -eq 13);
- if ($isEnter -or (('b', 'n', 'x') -contains $option))
- {
- if ($isEnter)
- {
- $option = $null
- }
- $guid.ToString($option) | clip
- Write-Host 'Copied.'
- return $true
- }
- else
- {
- Write-Host "Invalid option $option."
- Write-Host
- return $false
- }
- }
- $exit = $false
- while(-not $exit)
- {
- $exit = PromptGuid
- }
Add Comment
Please, Sign In to add comment