Skip to content

Commit

Permalink
Better testing for active user implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTruncer committed Jul 28, 2015
1 parent 109c569 commit e46ffd1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Invoke-WMITools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,18 @@ TBA
{
# Need to add in filtering here to stop if a "true" has been found for screensavers being active
Write-Verbose "Connecting to $computer"
Get-WMIObject Win32_Desktop -Credential $cred -computername $computer | ForEach-Object { $_.ScreenSaverActive } | Sort-Object | Get-Unique
Get-WMIObject Win32_Process -Credential $cred -computername $computer -filter 'name = "LogonUI.exe"' | ForEach-Object { $_.ProcessName } | Sort-Object | Get-Unique
[string]$ScreenshotActive = Get-RunningProcesses -User $User -Pass $Pass -Targets $Targets | Select-String ".scr"
[string]$LoginPrompt = Get-RunningProcesses -User $User -Pass $Pass -Targets $Targets | Select-String "LogonUI.exe"

# If either returned true, we can assume the user is not active at their desktop
if ($ScreenshotActive -or $LoginPrompt)
{
Write-Output "User is not present!"
}
else
{
Write-Output "User is at their desktop!"
}
}
}

Expand All @@ -421,4 +431,4 @@ TBA
}

# location for managing shares - http://windowsitpro.com/powershell/managing-file-shares-windows-powershell
# (Get-WmiObject Win32_Share -List).Create( "C:\Users\SonofFlynn\Downloads\apple", "pooperscooper", 0 )
# (Get-WmiObject Win32_Share -List).Create( "C:\Users\SonofFlynn\Downloads\apple", "testshare", 0 )

0 comments on commit e46ffd1

Please sign in to comment.