I'm trying to get the uptime of the system in ticks. I want to use a 64 bit method specifically to avoid the wrap-around that happens under the 32 bit version. I know there are other ways to see an uptime but I'm not using those as they cause other issues for my implementation.
I'm trying to use GetTickCount64() from Kernel32.dll as this should give me what I want.
$MethodDefinition = @"
[DllImport("kernel32")] extern static UInt64 GetTickCount64();
"@
$Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name 'Kernel32' -Namespace 'Win32' -PassThru
$Kernel32::GetTickCount64()
Unfortunately running this code gives me the following error:
WARNING: The generated type defines no public methods or properties.
Method invocation failed because [Win32.Kernel32] does not contain a method named 'GetTickCount64'.
I don't understand why this doesn't work on Windows 10, this method has been available since Vista.
Why can't this method be located?