The AppSense Environment Manager can provide you with valuable information related to the processes involved in login and logoff . Using Windows PowerShell you can easily retrieve this information to assist you in identifying problem spots.
When you install and configure Environment Manager (EM) it assumes control of your login and logout process, controlling each action and when they are performed. With an efficient design the many steps of your login process can easily be subdivided into separate threads that are performed in parallel. No doubt you will have some tasks that are dependent on previous tasks. If any of those tasks take an extended amount of time to complete, you can experience long login and even logoff times for users.
If you encounter any extended times, you can enable logging in EM to assist you in identifying trouble spots. The key items that you want to enable are the logging of “Trigger Action Times” and “User Logon Success” records. When you enable the logging of these events, you can see exactly how long logins are taking, as well as the time it takes each step to complete.
The function below will pull the events from the AppSense Event Log related to action times and output them as PowerShell objects, that you can further manipulate. Summary information such as total login and logout times are available to determine the total time an action takes. If you need to drill down and identify a specific step that is causing a delay, you can use the detailed information.
- <#
- .SYNOPSIS
- Parses the AppSense event log to extract information related to timings for actions.
- .DESCRIPTION
- The Get-ActionTimes function reads the AppSense event log for AppSense Environment Manager entries related to timing of AppSense events.
-
- Get-ActionTimes interrogates the AppSense event log and retrieves either "Trigger Action Times" or "User Logon Success" records. Records are parsed and then are outputed as an object.
-
- Requires that AppSense Environment Manager is configured to log Events 9662, and 9405 to the AppSense Event Log.
- .EXAMPLE
- C:PS>Get-ActionTimes -Server Server01 -ReportLevel Summary
-
- Action Duration EndTime UserID StartTime
- ------ -------- ------- ------ ---------
- Logoff 41 12/26/2011 8:11:00 PM DomainUser1 12/26/2011 8:11:00 PM
- Logon 10250 12/26/2011 8:10:52 PM Domainuser2 12/26/2011 8:10:42 PM
-
- Description
-
- -----------
-
- This command gets the AppSense Logon/Logoff records for Server 'Server01'.
-
- .EXAMPLE
- C:PS>Get-ActionTimes -ReportLevel Detailed
-
- Node : Login Script
- LogonTime : 12/26/2011 8:10:38 PM
- Duration : 1
- UserID : DomainUser1
- StartTime : 12/26/2011 8:10:42 PM
-
- Node : Populate Start Menu
- LogonTime : 12/26/2011 8:10:38 PM
- Duration : 1
- UserID : DomainUser1
- StartTime : 12/26/2011 8:10:42 PM
-
- Description
-
- -----------
-
- This command gets the detailed AppSense steps performed by Environment Manager for the local host.
- .PARAMETER ComputerName
- Name of the computer to pull the event logs from.
- .PARAMETER ReportLevel
- The level of reporting data to return.
-
- Possible values are either 'Detailed' or 'Summary'
- .PARAMETER UserName
- Retrieve only the information for the specified user. Otherwise all records will be retrieved.
-
- #>
- Function Get-ActionTimes
- {
- param
- (
- [parameter(Mandatory=$False,ValueFromPipeline=$False)]
- [alias("Server")]
- [String]$ComputerName = "localhost"
- ,
- [parameter(Mandatory=$False,ValueFromPipeline=$False)]
- [ValidateSet('Summary','Detailed')]
- [String]$ReportLevel = 'Summary'
- ,
- [parameter(Mandatory=$False,ValueFromPipeline=$False)]
- [string]$UserName = $Null
- )
-
- if ($ReportLevel -eq 'Summary')
- {
- Write-Verbose '$ReportLevel -eq Summary'
-
- $AppSenseCollection = @()
- Get-EventLog -ComputerName $ComputerName -LogName 'AppSense' -InstanceID 9662 | %{
-
- {
-
- $UserRegex = [regex]'Trigger: (?<Action>w*) Start Time: (?<StartTime>S*) End Time: (?<EndTime>S*) Duration: (?<Duration>d*)'
- $EventAction = $Matches['Action']
- $EventStartTime = $Matches['StartTime']
- $EventEndTime = $Matches['EndTime']
- $EventDuration = $Matches['Duration']
-
- Write-Verbose "EventAction = $EventAction"
- Write-Verbose "EventStartTime = $EventStartTime"
- Write-Verbose "EventEndTime = $EventEndTime"
- Write-Verbose "EventDuration = $EventDuration"
-
- $AppSenseInfo = New-Object PSObject -Property @{
- Action = [string]$EventAction
- StartTime = ([datetime]$EventStartTime).ToLocalTime()
- EndTime = ([datetime]$EventEndTime).ToLocalTime()
- Duration = [Int32]$EventDuration
- }
-
- $AppSenseCollection += $AppSenseInfo
- }
- }
-
- Write-Output $AppSenseCollection
-
- }
- elseif ($ReportLevel -eq 'Detailed')
- {
- Write-Verbose '$ReportLevel -eq Detailed'
-
- $AppSenseCollection = @()
- Get-EventLog -ComputerName $ComputerName -LogName 'AppSense' -InstanceID 9405 | %{
- {
- $UserRegex = [regex]'Logon Time: (?<LogonTime>S*) Node Name: (?<Node>.*) Start Time: (?<StartTime>S*) Duration: (?<Duration>d*)ms.'
- $LogonTime = $Matches['LogonTime']
- $Node = $Matches['Node']
- $StartTime = $Matches['StartTime']
- $Duration = $Matches['Duration']
-
- Write-Verbose "LogonTime = $LogonTime"
- Write-Verbose "Node = $Node"
- WRite-Verbose "StartTime = $StartTime"
- Write-Verbose "Duration = $Duration"
- $AppSenseInfo = New-Object PSObject -Property @{
- LogonTime = ([datetime]$LogonTime).ToLocalTime()
- Node = [string]$Node
- StartTime = ([datetime]$StartTime).ToLocalTime()
- Duration = [Int32]$Duration
-
- }
- $AppSenseCollection += $AppSenseInfo
- }
-
- }
- $AppSenseCollection
-
- }
-
- }


