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

This entry was posted in PowerShell v5, WMFv5. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s