Force terminates the active logged-in user session on Windows endpoints immediately
This Automox Worklet™ force logs off the currently logged-in user and terminates their active session on Windows endpoints. The Worklet uses PowerShell to detect the logged-in user, force disconnect their session, and validate that the session has been fully terminated.
The Worklet employs Win32_ComputerSystem and Win32_OperatingSystem classes to manage session termination. During remediation, it invokes the Win32Shutdown method with forced logout flag (4) to immediately disconnect the user without notifications to running applications.
After initiating the logout, the Worklet enters a verification loop that monitors endpoint session status for up to three minutes, checking every five seconds to confirm the user has been disconnected. This confirms the logout command executed successfully before reporting completion.
Forcing user session termination is essential for security, compliance, and operational efficiency. Organizations use session termination to enforce access control policies, disconnect users during security incidents, or revoke access when users leave departments or organizations.
Session termination also supports maintenance windows, software deployments, and system updates that require endpoints to be in a disconnected state. This prevents data loss from unsaved work and ensures critical updates can proceed without user interference or approval delays.
For IT operations teams managing large endpoint fleets, automated session termination eliminates manual intervention and maintains consistent enforcement across all Windows workstations and servers. This is particularly valuable for organizations with distributed teams or high turnover rates.
Evaluation phase: Queries the endpoint using Get-CimInstance to identify the currently logged-in user by parsing the Win32_ComputerSystem UserName property. If a user is detected, the endpoint is flagged for remediation. If no user is logged in, the endpoint is marked compliant and the Worklet exits.
Remediation phase: Invokes Win32Shutdown method with forced logout flag (4) to immediately disconnect the logged-in user without application notifications. The Worklet then loops for up to three minutes checking endpoint session status every five seconds. Once the session is confirmed disconnected, or if three minutes elapse, the Worklet reports success or failure to the Automox Activity Log.
Windows endpoints: Workstations or servers (Windows 7 and later)
PowerShell 3.0 or later
Administrator privileges to invoke Win32_OperatingSystem methods
No special configuration required; the Worklet operates with default Windows API access
After the Worklet completes remediation, the targeted endpoint enters a logged-off state. All user sessions are terminated, applications close immediately without notification, and the endpoint displays the Windows login screen. The Automox Activity Log contains detailed output confirming the username that was logged off and the timestamp of the successful disconnection.
If the Worklet times out after three minutes of verification, it reports failure to the Activity Log. This may occur if the user account is protected by special permissions or if the endpoint is unresponsive. System administrators can then investigate further or manually disconnect the session using remote administration tools.
Run this Worklet on a pilot Windows endpoint and review evaluation output for force log off current user.
Confirm Automox activity logs show successful completion and exit code 0.
Verify endpoint state using checks aligned to evaluation script logic, such as Get-CimInstance, Select-Object, Write-Output.
Validate remediation effects from script operations such as Get-CimInstance, Select-Object, Write-Output, then rerun evaluation for compliance.


By submitting this form you agree to our Master Services Agreement and Privacy Policy.
Already have an account? Log in
Consider Worklets your easy button
A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklet automation scripts perform configuration, remediation, and the installation or removal of applications and settings across Windows, macOS, and Linux.

AUTOMOX + WORKLETS™
Uncover new possibilities with simple, powerful automation.
By submitting this form you agree to our Master Services Agreement and Privacy Policy