Comments on: three ways to track logins using dbatools https://dbatools.io/track-logins/ the community's sql powershell module Tue, 23 Apr 2019 17:16:37 +0000 hourly 1 https://wordpress.org/?v=5.3.4 By: sam https://dbatools.io/track-logins/#comment-63865 Tue, 23 Apr 2019 17:16:37 +0000 https://dbatools.io/?p=7432#comment-63865 Hi I have a similar required to capture – username, login time, logout time. can you please share me scripts to do the same. thank you.

]]>
By: Chrissy LeMaire https://dbatools.io/track-logins/#comment-51241 Wed, 20 Feb 2019 09:12:39 +0000 https://dbatools.io/?p=7432#comment-51241 ]]> Hey Luke, the auditing is primarily intended to ensure that all supported applications are known and considered/planned for when performing the migration. When SSMS connects to a server, it’s more of an ad-hoc behavior that likely does not need need to be managed. If you would like to audit for purposes other than migrations or if your end-users are connecting via ssms, then you can remove the filter 👍

]]>
By: Luke https://dbatools.io/track-logins/#comment-51118 Wed, 20 Feb 2019 00:49:12 +0000 https://dbatools.io/?p=7432#comment-51118 Could you, please, explain to me why you do not audit anything comeing from ssms?

not like ‘Microsoft SQL Server Management Studio%’

Thank you!
Luke

]]>
By: Pollus Brodeur https://dbatools.io/track-logins/#comment-47136 Tue, 05 Feb 2019 17:17:15 +0000 https://dbatools.io/?p=7432#comment-47136 Hi Chrissy,

Great article

I wanted to use the Default Trace to get this information but something is bothering me. Default trace does not capture Login or Logout event id (14,15). This means that it does not garanty all connections will be captured. I tried connecting and running a simple query the close the connection. It was not in the trace. It’s worth warning the reader. They must be aware before taking migration decision based on incomplete data.

]]>
By: Greg https://dbatools.io/track-logins/#comment-6529 Tue, 12 Jun 2018 13:18:28 +0000 https://dbatools.io/?p=7432#comment-6529 I got it working, here is what I found.
The $Servers is not working – I ran this before the script above and that is when it failed (not this ype, this created the null issue): $servers = Get-DbaRegisteredServer -SqlInstance localhost
So Something with that is not working. Still not sure.I ran the following and it returned nothing (but I am newish to powershell so this may not be right)
$servers = Get-DbaRegisteredServer -SqlInstance localhost
write-output $servers
I then ran the next command but i took out the ‘$servers |’ and ran without, it prompted me for the instance, i typed it in and everything worked. So I am not sure what the issue with registering the server is. It is a SQL Server 2017 if that makes any difference. Here is what worked.
# Collect the results into a variable so that the bulk import is supafast
$results = Get-DbaXESession -Session ‘Login Tracker’ | Read-DbaXEFile |
Select-Object server_instance_name, server_principal_name, client_hostname, database_name, client_app_name, timestamp

# Bulk import to the centralized database in an efficient manner (piping would write line by line)
Write-DbaDataTable -InputObject $results -SqlInstance localhost -Database inventory -Table watchlogins

Thank you for your help

]]>
By: Chrissy LeMaire https://dbatools.io/track-logins/#comment-6527 Tue, 12 Jun 2018 12:46:52 +0000 https://dbatools.io/?p=7432#comment-6527 The command index is out of date, the command does exist. You can see all our commands using: Find-DbaCommand.

Did you add any wheres and did you ensure the Login Tracker session is running?

#ensure you have servers assigned
$servers

#ensure your login tracker is running
$servers | Get-DbaXESession -Session ‘Login Tracker’

]]>
By: Greg https://dbatools.io/track-logins/#comment-6522 Tue, 12 Jun 2018 12:01:48 +0000 https://dbatools.io/?p=7432#comment-6522 I understand it is null, i guess my question is, using the script, why is it null? I can see data in the session in SSMS so there is data. It also appears you use the function ‘Read-DbaXEFile’ but this function is no longer in dbatools. (It is not listed in the command index) I am starting to think that is why the variable is null.
Thank you

]]>
By: Chrissy LeMaire https://dbatools.io/track-logins/#comment-6455 Mon, 11 Jun 2018 20:32:49 +0000 https://dbatools.io/?p=7432#comment-6455 Hey Greg, that’s because your result set is null. In my own script I assign the collection to a variable then check to see if the variable is null: if ($results) { write-dbadatatable -inputobject $results).

]]>
By: Greg https://dbatools.io/track-logins/#comment-6422 Mon, 11 Jun 2018 13:54:42 +0000 https://dbatools.io/?p=7432#comment-6422 I am trying to run the collector session-insert.ps1 script for extended events and I am getting the following error. I updated dbatools to latest. I am on sql 2017 on a localhost using all the standard scripts you provided. The first command executes without error but the second command fails. Everything worked until than. Any ideas? Thanks
Write-DbaDataTable : Cannot validate argument on parameter ‘InputObject’. The argument is null. Provide a valid value for the argument, and then try running the command again.
At line:6 char:33
+ Write-DbaDataTable -InputObject $results -SqlInstance localhost -Data …
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Write-DbaDataTable], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Write-DbaDataTable

]]>
By: Chrissy LeMaire https://dbatools.io/track-logins/#comment-1683 Wed, 11 Apr 2018 12:24:23 +0000 https://dbatools.io/?p=7432#comment-1683 Cool, Hermann! Did you use which Event did you end up using? sql_statements_starting?

We have a lot of new (since Jan) XE stuff – check out dbatools.io/xevents

]]>