Monthly Archive

Categories

WMF 5.0 April 2015 preview – – creating guid

Creating a GUID has always been possible with PowerShell – you just had to drop into .NET

 

£> [System.Guid]::NewGuid()

Guid
----
46c130ca-39ff-463c-b7fb-ed728a1c134f

 

With the latest WMF 5.0 preview life gets easier:

£> Get-Command New-Guid -Syntax

New-Guid [<CommonParameters>]

 

£> New-Guid

Guid
----
112866a5-1662-4265-b851-f9086607bcb2

 

The New-Guid cmdlet happily creates a GUID for you – and you don’t have to remember the >NET syntax.

 

If you want the GUID in a variable as a string

£> $guid = New-Guid | select -ExpandProperty Guid
£> $guid
5c832d40-0ea4-4b42-b0bd-b228da008c9d

Comments are closed.