Guest User

Untitled

a guest
May 27th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. Function PromptGuid
  2. {
  3. $guid = New-Guid
  4. Write-Host -NoNewline "Choose a format to copy (r to regen): "
  5. $op_pos = $host.UI.RawUI.CursorPosition
  6. Write-Host
  7. Write-Host " (enter) : $($guid.ToString())"
  8. Write-Host " B : $($guid.ToString('B'))"
  9. Write-Host " N : $($guid.ToString('N'))"
  10. Write-Host " X : $($guid.ToString('X'))"
  11. $end_pos = $host.UI.RawUI.CursorPosition
  12.  
  13. $host.UI.RawUI.CursorPosition = $op_pos
  14. $option = ($host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")).Character
  15. $host.UI.RawUI.CursorPosition = $end_pos
  16.  
  17. if ($option -ieq 'r')
  18. {
  19. Clear-Host
  20. return $false
  21. }
  22.  
  23. $isEnter = ([int]$option -eq 13);
  24.  
  25. if ($isEnter -or (('b', 'n', 'x') -contains $option))
  26. {
  27. if ($isEnter)
  28. {
  29. $option = $null
  30. }
  31.  
  32. $guid.ToString($option) | clip
  33.  
  34. Write-Host 'Copied.'
  35. return $true
  36. }
  37. else
  38. {
  39. Write-Host "Invalid option $option."
  40. Write-Host
  41. return $false
  42. }
  43. }
  44.  
  45. $exit = $false
  46. while(-not $exit)
  47. {
  48. $exit = PromptGuid
  49. }
Add Comment
Please, Sign In to add comment