Every Windows installation has a unique UUID that you can use to distinguish machines. While computer names can change, the UUID won’t:
PS> (Get-CimInstance -Class Win32_ComputerSystemProduct).UUID 4C4C4544-004C-4710-8051-C4C04F443732
In reality, the UUID is just a GUID (Globally Unique Identifier), which comes in different formats:
$uuid = (Get-CimInstance -Class Win32_ComputerSystemProduct).UUID [Guid]$guid = $uuid "d","n","p","b","x" | ForEach-Object { '$guid.ToString("{0}") = {1}' -f $_, $guid.ToString($_) }
Here is the result:
$guid.ToString("d")= 4c4c4544-004c-4710-8051-c4c04f443732 $guid.ToString("n")= 4c4c4544004c47108051c4c04f443732 $guid.ToString("p")= (4c4c4544-004c-4710-8051-c4c04f443732) $guid.ToString("b")= {4c4c4544-004c-4710-8051-c4c04f443732} $guid.ToString("x")= {0x4c4c4544,0x004c,0x4710,{0x80,0x51,0xc4,0xc0,0x4f,0x44,0x37,0x32}}
If you’d like to create a new UUID (or GUID) to get a unique identifier for whatever you like to tag, i.e. temporary file names, the New-Guid cmdlet was introduced in PowerShell 5:
PS> New-Guid Guid ---- 16750457-9a7e-4510-96ab-f9eef7273f3e
It basically runs this .NET call behind the scenes:
PS> [Guid]::NewGuid() Guid ---- 6cb3cb1a-b094-425b-8ccb-e74c2034884f
psconf.eu – PowerShell Conference EU 2019 – June 4-7, Hannover Germany – visit www.psconf.eu There aren’t too many trainings around for experienced PowerShell scripters where you really still learn something new. But there’s one place you don’t want to miss: PowerShell Conference EU – with 40 renown international speakers including PowerShell team members and MVPs, plus 350 professional and creative PowerShell scripters. Registration is open at www.psconf.eu, and the full 3-track 4-days agenda becomes available soon. Once a year it’s just a smart move to come together, update know-how, learn about security and mitigations, and bring home fresh ideas and authoritative guidance. We’d sure love to see and hear from you!