1

I am trying to get a key using PowerShell that will uniquely identify a Windows computer that is relatively durable, i.e., doesn't change between re-installs of Windows.

I came across Windows.System.Profile.SystemIdentification which is part of the Windows UWP API but unfortunately so far, I have been unsuccessful in getting this with PowerShell.

How to get Windows 10 Device ID in UWP application?

I have been trying for the past several days and the farthest I have gone is the following:

PS> [Windows.System.Profile.SystemIdentification,Windows.System.Profile,ContentType=WindowsRuntime] | Out-Null

PS> $systemID = [Windows.System.Profile.SystemIdentification]::GetSystemIdForPublisher()

PS> $systemID

Id                 Source
--                 ------
System.__ComObject   Uefi

PS> $systemID | Get-Member

TypeName: Windows.System.Profile.SystemIdentificationInfo

Name                      MemberType Definition                                                     
----                      ---------- ----------                                                     
CreateObjRef              Method     System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Equals                    Method     bool Equals(System.Object obj)                                 
GetHashCode               Method     int GetHashCode()                                              
GetLifetimeService        Method     System.Object GetLifetimeService()                             
GetType                   Method     type GetType()                                                 
InitializeLifetimeService Method     System.Object InitializeLifetimeService()                      
ToString                  Method     string ToString()                                              
Id                        Property   Windows.Storage.Streams.IBuffer Id {get;}                      
Source                    Property   Windows.System.Profile.SystemIdentificationSource Source {get;}

How can I get the Id property which has a type of Windows.Storage.Streams.IBuffer Id {get;} ?

bombi
  • 21
  • 3
  • So, you are trying to replicate this [How can I get a signature for a Windows system that will remain unchanged even if the user reinstalls Windows?](https://devblogs.microsoft.com/oldnewthing/20180131-00/?p=97945) , in PowerShell? – postanote Oct 14 '20 at 21:10
  • @postanote Yes. – bombi Oct 15 '20 at 04:10

2 Answers2

2

For this IBuffer you shuld use

Windows.Security.Cryptography.CryptographicBuffer.EncodeToHexString( systemID );
Yogan
  • 131
  • 5
1

In case someone else comes across this, here's a working version of the info provided above...

# Use reflection syntax ( [class, namespace, contentType] ) to call GetSystemIdForPublisher()

$systemID = [Windows.System.Profile.SystemIdentification, Windows.System.Profile, ContentType = WindowsRuntime]::GetSystemIdForPublisher()

# And because PowerShell was designed for use by AI and people who think in hieroglyphics:

[Windows.Security.Cryptography.CryptographicBuffer, Windows.Security.Cryptography, ContentType = WindowsRuntime].
GetMethod('EncodeToHexString',  [type[]]@([Windows.Storage.Streams.IBuffer, Windows.Storage.Streams, ContentType = WindowsRuntime])).
Invoke($null,  @($systemID.Id))
  • Thanks. I didn't know what to do with 'System.__ComObject'. I think this will help me in other implementations of WDP calling. – Garric Aug 26 '23 at 10:32