Skip to content

Instantly share code, notes, and snippets.

@XPlantefeve
Created March 19, 2015 16:23
Show Gist options
  • Select an option

  • Save XPlantefeve/f91e144b7200338a7122 to your computer and use it in GitHub Desktop.

Select an option

Save XPlantefeve/f91e144b7200338a7122 to your computer and use it in GitHub Desktop.
logon index / find a computer's main user
$ComputerName = $env:ComputerName
$test = Import-Csv -Path "log:\computers\${ComputerName}.log" -Delimiter ' ' -header @('user','date','time')
$t2 = $test |
select user,date,@{
name='logonage';
expression={
1 / ((Get-Date) - [DateTime]$_.date).Days}
} |
group user |
select Count,Name,@{
Name='index';
Expression={
"{0:N2}" -f (($_.Group | measure -Property logonage -Average).Average * $_.count * 10)
}
}
$t2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment