# $cs.Sys_isUserLoggedOn

> Checks whether a user is currently logged on to the desktop/console session. Takes no parameters.

Source: https://docs.capaone.com/capainstaller/powerpacks/cs-sys-isuserloggedon/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Checks whether a user is currently logged on to the desktop/console session. Takes no parameters.

### Syntax

$cs.Sys_isUserLoggedOn()

### Parameters

None.

### Return value

Boolean. `$true` if a user is currently logged on, otherwise `$false`.

### Example

**PowerShell**

Skip a disruptive forced restart when a user is currently logged on:

```powershell
if ($cs.Sys_isUserLoggedOn())
{
  $cs.Job_WriteLog("A user is logged on, skipping forced restart")
}
```

Branch between running a step in the logged-on user's context and a silent SYSTEM-only path:

```powershell
if ($cs.Sys_isUserLoggedOn())
{
  $cs.Job_WriteLog("User is logged on, running configuration script in user context")
  Invoke-RunAsLoggedOnUser -command "powershell.exe" -arguments "-ExecutionPolicy Bypass -File `"$global:Packageroot\Configure-UserSettings.ps1`""
}
else
{
  $cs.Job_WriteLog("No user logged on, skipping user-context configuration")
}
```

### Related functions

[$cs.Sys_ExistProcess](/capainstaller/powerpacks/cs-sys-existprocess/)
