I start with powershell, and I wrote a small and simple code that writes a new GUID to the board.
I used this line:
Set-Clipboard (New-Guid).Guid
It works, but I could not find how to write the GUID with curly brackets.
Surely there are already answers on the subject, but I had a hard time finding.
Maybe give someone an idea?
Thank you!
CodePudding user response:
Alternative implementation / Cryptographic Guid
function New-CryptoGuid {
$bytes = [System.Security.Cryptography.RandomNumberGenerator]::GetBytes(16)
return [System.Guid]::new($bytes).ToString("B")
}
$guid = New-CryptoGuid
Write-Host $guid
Set-Clipboard $guid
References
System.Guid
Guid.NewGuid Method - Remarks
System.Guid - Constructor
RandomNumberGenerator.GetBytes Method