<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Use PowerShell to Find Logon Sessions</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/04/use-powershell-to-find-logon-sessions.aspx</link><description>Summary : Learn how to use Windows PowerShell to discover logon session information for remote computers.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Use PowerShell to Find Logon Sessions</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/04/use-powershell-to-find-logon-sessions.aspx#3433597</link><pubDate>Mon, 06 Jun 2011 14:43:48 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3433597</guid><dc:creator>joel de la torre</dc:creator><description>&lt;p&gt;I also this on my blog at &lt;a rel="nofollow" target="_new" href="http://datatypes.blogspot.com"&gt;http://datatypes.blogspot.com&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3433597" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell to Find Logon Sessions</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/04/use-powershell-to-find-logon-sessions.aspx#3433463</link><pubDate>Sun, 05 Jun 2011 17:54:08 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3433463</guid><dc:creator>Sean Kearney</dc:creator><description>&lt;p&gt;Joel&lt;/p&gt;
&lt;p&gt;I like that! Another tool to add to our kits! &amp;nbsp;I LOVE the Power of community here! &amp;nbsp;Thanks for contributing. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have a few minutes, could you pop that into the Script Repository? &amp;nbsp; NICE JOB! :)&lt;/p&gt;
&lt;p&gt;Sean&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3433463" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell to Find Logon Sessions</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/04/use-powershell-to-find-logon-sessions.aspx#3433426</link><pubDate>Sat, 04 Jun 2011 22:42:45 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3433426</guid><dc:creator>joel de la torre</dc:creator><description>&lt;p&gt;If you have enabled &amp;#39;Audit account logon Events&amp;#39; on your Win2008 server you can query for event: 4768; A Kerberos Ticket Request. &amp;nbsp;The event has the username and computername where the request originated from. &amp;nbsp;Just as your request isn&amp;#39;t perfect, neither is this. &amp;nbsp;Its just an alternative if you dont have a share where all your users are connected to. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;function Get-UserComputerName {&lt;/p&gt;
&lt;p&gt;	&amp;lt;#&lt;/p&gt;
&lt;p&gt;.SYNOPSIS&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Searches a specified Domain Controller for the computername of a logged on user. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;.DESCRIPTION&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Queries a DC for Event ID 4768 (Kerberos authentication ticket,TGT) request from the servers Security&lt;/p&gt;
&lt;p&gt; &amp;nbsp; event log.&lt;/p&gt;
&lt;p&gt;.PARAMETER UserName&lt;/p&gt;
&lt;p&gt; &amp;nbsp; SamAccount name of the user to search for&lt;/p&gt;
&lt;p&gt;.EXAMPLE&lt;/p&gt;
&lt;p&gt; &amp;nbsp; PS&amp;gt; .\Get-UserComputerName -UserName &amp;quot;John_Doe&amp;quot; -Server &amp;quot;My_DC&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Searches for user John_Doe on Domain Controller My_DC&lt;/p&gt;
&lt;p&gt;.EXAMPLE&lt;/p&gt;
&lt;p&gt;	PS&amp;gt; .\Get-UserComputerName -Username &amp;quot;John_Doe&amp;quot;&lt;/p&gt;
&lt;p&gt;	Searches for user John_Doe using the logged on server name for the current user&lt;/p&gt;
&lt;p&gt;	running the script. &lt;/p&gt;
&lt;p&gt;.EXAMPLE &lt;/p&gt;
&lt;p&gt;	PS&amp;gt; .\Get-UserComputerName &lt;/p&gt;
&lt;p&gt;	Searches the current user on the logged on server name&lt;/p&gt;
&lt;p&gt;#&amp;gt;&lt;/p&gt;
&lt;p&gt;	param([string]$username = $env:username,[string]$server = $env:logonserver)&lt;/p&gt;
&lt;p&gt;	$ErrorActionPreference = &amp;quot;silentlycontinue&amp;quot;&lt;/p&gt;
&lt;p&gt;	if ($server.StartsWith(&amp;quot;\\&amp;quot;)) {$server = $server.Remove(0,2)}&lt;/p&gt;
&lt;p&gt;	$events = Get-WinEvent -ComputerName $server -MaxEvents 5 -FilterHashTable @{logname=&amp;quot;security&amp;quot;;id=4768;data=$username}&lt;/p&gt;
&lt;p&gt;	# Check if error has been raised from EventLog Query.&lt;/p&gt;
&lt;p&gt;	if (!$?) {Write-Warning &amp;quot;No successful logon events were found on Server: $server for Username: $username&amp;quot; &lt;/p&gt;
&lt;p&gt;		break&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	foreach ($event in $events) {&lt;/p&gt;
&lt;p&gt;		$myObject = New-Object -TypeName system.Object&lt;/p&gt;
&lt;p&gt;		[string]$Computer = $event.message.split(&amp;quot;`n&amp;quot;) | Select-String &amp;quot;Client Address&amp;quot;&lt;/p&gt;
&lt;p&gt;		$addressLine = $computer.replace(&amp;quot;Client Address:&amp;quot;,&amp;#39;&amp;#39;)&lt;/p&gt;
&lt;p&gt;		$addressLine = $addressLine.trim()&lt;/p&gt;
&lt;p&gt;		if ($addressLine.startswith(&amp;quot;::ffff:&amp;quot;)) { $address = $addressLine.replace(&amp;quot;::ffff:&amp;quot;,&amp;#39;&amp;#39;) }&lt;/p&gt;
&lt;p&gt;		$DNSResult = [system.Net.Dns]::Resolve($address)&lt;/p&gt;
&lt;p&gt;		$ComputerName = $DNSResult.HostName&lt;/p&gt;
&lt;p&gt;		$timeStamp = $event.timecreated&lt;/p&gt;
&lt;p&gt;		$myObject | Add-Member -MemberType noteproperty -Name AuthDC -Value $server&lt;/p&gt;
&lt;p&gt;		$myObject | Add-Member -MemberType noteproperty -Name TimeStamp -Value $timeStamp&lt;/p&gt;
&lt;p&gt;		$myObject | Add-Member -MemberType noteproperty -Name UserName -Value $username&lt;/p&gt;
&lt;p&gt;		$myObject | Add-Member -MemberType noteproperty -Name IPAddress -Value $address&lt;/p&gt;
&lt;p&gt;		$myObject | Add-Member -MemberType noteproperty -Name ComputerName -Value $computerName&lt;/p&gt;
&lt;p&gt;		$myObject&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3433426" width="1" height="1"&gt;</description></item></channel></rss>