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