Skip to content

Commit

Permalink
Merge pull request #16 from tobraha/master
Browse files Browse the repository at this point in the history
Remove Get-IdleTime function
  • Loading branch information
RCShoemaker authored May 19, 2021
2 parents 300a4f4 + d78a21a commit 0c52e74
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 78 deletions.
77 changes: 0 additions & 77 deletions ATG-PS-Functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -501,83 +501,6 @@ Function Get-ThunderBolt {
}
}

function Get-IdleTime
{
[CmdletBinding()]
Param (
[Parameter ()]
[string[]]
$ComputerName = 'localhost'
)

begin
{
$Header = 'UserName','SessionName','ID','State','IdleTime','LogonTime'
$No_Connection = '-- No Connection --'
}

process
{
foreach ($CN_Item in $ComputerName)
{
if (Test-Connection -ComputerName $CN_Item -Count 1 -Quiet)
{
quser /server:$CN_Item |
Select-Object -Skip 1 |
ForEach-Object {($_ -replace '\s{2,}', ',').Trim()} |
ConvertFrom-Csv -Header $Header |
ForEach-Object {
if ($_.IdleTime -eq 'none' -Or '.')
{
$IdleTime = "Keyboard/Mouse Currently Active"
} else {
$IdleTime = [timespan]$_.IdleTime
}
[PSCustomObject]@{
ComputerName = $CN_Item
UserName = $_.UserName
SessionName = $_.SessionName
ID = $_.ID
State = $_.State
IdleTime = $IdleTime
LogonTime = [datetime]$_.LogonTime
}
}
}
else
{
[PSCustomObject]@{
ComputerName = $CN_Item
UserName = $No_Connection
SessionName = $No_Connection
ID = $No_Connection
State = $No_Connection
IdleTime = $No_Connection
LogonTime = $No_Connection
}
}
} # end >> foreach ($CN_Item in $ComputerName)
} # end >> process {}

end {}

<#
.DESCRIPTION
Checks active logon sessions to check for idle time and time of logon

.LINK
https://www.reddit.com/r/PowerShell/comments/8r56tr/getting_idle_time_for_logged_on_domain_users#t1_e0oja92

.PARAMETER ComputerName
A comma-separated list of hostnames and/or IP Addresses; must have admin access to all computers. Default is 'localhost'.

.EXAMPLE
Get-IdleTime
Get-IdleTime -ComputerName 10.0.0.55,192.168.50.78,SERVER01
#>

} # end >> function Get-IdleTime

Function Get-InternetHealth {
######### Absolute monitoring values ##########
$maxpacketloss = 2 #how much % packetloss until we alert.
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Export-LDAPSCertificate
Get-ADUserPassExpirations
Get-ATGPS
Get-DiskUsage
Get-IdleTime
Get-InternetHealth
Get-ThunderBolt
Install-AppDefaults
Expand Down

0 comments on commit 0c52e74

Please sign in to comment.