Thursday, 5 May 2022

PowerShell New GUID

https://riptutorial.com/powershell/example/4952/creating-new-guid-instantly

PowerShell New GUID

Use existing .NET classes instantly with PowerShell by using [class]::Method(args):

PS C:\> [guid]::NewGuid()

Guid
----
8874a185-64be-43ed-a64c-d2fe4b6e31bc

Similarly, in PowerShell 5+ you may use the New-Guid cmdlet:

PS C:\> New-Guid

Guid
----
8874a185-64be-43ed-a64c-d2fe4b6e31bc

To get the GUID as a [String] only, referenced the .Guid property:

[guid]::NewGuid().Guid

 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive