24 lines
825 B
PowerShell
24 lines
825 B
PowerShell
|
function Get-WindowsThreadSliceTime {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Used to determine the windows thread slice time. Useful for Invoke-JobRunner
|
||
|
#>
|
||
|
[CmdletBinding(DefaultParameterSetName = 'Milliseconds')]
|
||
|
param (
|
||
|
[Parameter(ParameterSetName = "Milliseconds")]
|
||
|
[switch]$Milliseconds,
|
||
|
|
||
|
[Parameter(ParameterSetName = "Ticks")]
|
||
|
[switch]$Ticks
|
||
|
)
|
||
|
Add-Type -Assembly "System.ServiceModel.Internals"
|
||
|
$assembly = [System.AppDomain]::CurrentDomain.GetAssemblies().Where({ $_.GetName().Name -match 'System.ServiceModel.Internals' })
|
||
|
$timer = $assembly.GetTypes().Where({ $_.Name -eq 'IOThreadTimer' })
|
||
|
$timerValue = $timer.GetProperty("SystemTimeResolutionTicks").GetValue($null)
|
||
|
|
||
|
if ($Milliseconds) {
|
||
|
return $timerValue / 10000
|
||
|
} else {
|
||
|
return $timerValue
|
||
|
}
|
||
|
}
|