Skip to content

Instantly share code, notes, and snippets.

@Jackbennett
Created September 22, 2017 10:29
Show Gist options
  • Save Jackbennett/7e9794727ec86a284b66a5ad87ac3ddf to your computer and use it in GitHub Desktop.
Save Jackbennett/7e9794727ec86a284b66a5ad87ac3ddf to your computer and use it in GitHub Desktop.
$ 1..1000 | %{ measure-command { ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")} }| sort -Descending -Property TotalMilliseconds | select -First 20 -Property TotalMilliseconds
TotalMilliseconds
-----------------
9.2754
0.9975
0.195
0.191
0.1877
0.1817
0.1768
0.1681
0.1532
0.1509
0.1489
0.1473
0.1433
0.133
0.1291
0.1274
0.1228
0.1165
0.1158
0.1135
$ $me = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
$ 1..1000 | %{ measure-command { $me} }| sort -Descending -Property TotalMilliseconds | select -First 20 -Property TotalMilliseconds
TotalMilliseconds
-----------------
9.8323
0.93
0.0586
0.0582
0.0516
0.0496
0.0473
0.0437
0.0407
0.039
0.0384
0.0321
0.0317
0.0317
0.0314
0.0288
0.0284
0.0271
0.0254
0.0254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment