{"id":4963,"date":"2012-09-17T00:01:00","date_gmt":"2012-09-17T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/09\/17\/powershell-and-user-access-logging\/"},"modified":"2012-09-17T00:01:00","modified_gmt":"2012-09-17T00:01:00","slug":"powershell-and-user-access-logging","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-user-access-logging\/","title":{"rendered":"PowerShell and User Access Logging"},"content":{"rendered":"<p><b>Summary<\/b>: Learn about using Windows PowerShell to manage the new User Access Logging feature in Windows Server 2012.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Today we have as our guest blogger, Brent Forman. Here is a little bit about Brent.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6712.Brent.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6712.Brent.jpg\" alt=\"Photo of Brent Forman\" title=\"Photo of Brent Forman\" \/><\/a><\/p>\n<p style=\"padding-left: 30px\">Brent Forman is senior program manager in the Windows Server division at Microsoft. Brent has extensive experience in large scale IT operations and management through working in Windows Server for more than eight years and providing leadership to internal R&amp;D datacenter operations across the Microsoft Server and Tools business.<\/p>\n<p><b>User Access Logging<\/b> (UAL) in Windows Server 2012 presents new opportunities to IT Pros by providing an at-a-glance view of server role client demand within an enterprise environment. This can help IT Pros understand and optimize server resource usage and identify potential bottlenecks and gaps across an IT infrastructure.&nbsp;<b>User Access Logging<\/b> fundamentally aggregates basic usage tracking of a server&rsquo;s roles by measuring client requests over time of a local Windows Server 2012 installation. This blog post is intended to show how using a few quick Windows PowerShell cmdlets can give you the data you need to easily quantify client requests over time, for a specific role or application, on a specific server.<\/p>\n<h2>UAL architecture<\/h2>\n<p>The UAL service logs unique client access requests, in the form of IP addresses and user names, of server roles on the local Windows Server 2012. Client access request events are aggregated and stored locally in near real time (a separate database is not required). This information can then be queried locally or remotely via Windows PowerShell or WMI, by a user with administrative privileges.<\/p>\n<p style=\"padding-left: 30px\"><b>Notes<\/b> &nbsp;By design, there is a default 24-hour delay before events can be retrieved by Windows PowerShell cmdlets or WMI queries. The UAL service&rsquo;s default configuration is to start, run, and collect data. No UAL data is sent to Microsoft. This service is intended for administrators only.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3808.wes-9-2-12-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3808.wes-9-2-12-1.png\" alt=\"Image of design\" title=\"Image of design\" \/><\/a><\/p>\n<h2>UAL Windows PowerShell cmdlets<\/h2>\n<p>The following are the main cmdlets you will use.<\/p>\n<ul>\n<li><b>Get-UalOverview<\/b><b> &nbsp;<\/b>Retrieves and displays basic UAL data for all installed server roles (except DNS and Hyper-V, which have separate, dedicated UAL cmdlets)<\/li>\n<li><b>Get-UalUserAccess<\/b><b> &nbsp;<\/b>Retrieves and displays UAL data by client user names and roles<\/li>\n<li><b>Get-UalDailyUserAccess<\/b><b> &nbsp;<\/b>Retrieves and displays UAL data by client user name and date<\/li>\n<li><b>Get-UalDeviceAccess<\/b> <b>&nbsp;<\/b>Retrieves and displays UAL data by client device IP and roles<\/li>\n<li><b>Get-UalDailyDeviceAccess<\/b><b> &nbsp;<\/b>Retrieves and displays UAL data by client device IP and date<\/li>\n<\/ul>\n<p>See <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/jj574126\">Managing User Access Logging<\/a> for a complete list of UAL cmdlets.<\/p>\n<p style=\"padding-left: 30px\"><b>Note<\/b> &nbsp;Be sure to check out <b>Get-UalSystemId<\/b> to see what is provided there that might meet your needs.<\/p>\n<p>Of particular interest to the IT Pro would be the <b>ActivityCount<\/b> and <b>AccessCount<\/b> output for the last four cmdlets in the previous list. For remote administrator retrieval, exposing this data is a potential gold mine to assist with planning server resources efficiently.<\/p>\n<p>Data that is retrieved with these cmdlets can help an administrator answer questions like:<\/p>\n<ul>\n<li>Which server is getting the most requests from clients?<\/li>\n<li>Which server is getting the most requests from unique clients vs. generic clients?<\/li>\n<li>What server roles are getting the most activity and at what point in the cycle (for example: day, week, quarter, or year)?<\/li>\n<li>Coupled with performance tool data, at what point do new resources need to be brought to bear, or at what point in the cycle?<\/li>\n<li>Which clients are the most active in my environment?<\/li>\n<li>How efficiently are my current servers being used?&nbsp;Does the load warrant a separate dedicated server?<\/li>\n<\/ul>\n<h2>UAL Windows PowerShell cmdlet examples and output<\/h2>\n<p><b>Get-UalOverview<\/b> is meant as a quick inventory of what is installed on a server and what is active. Most of the server roles will appear in the output, but only those with an entry for <b>FirstSeen<\/b> and <b>LastSeen<\/b> are installed and actively servicing client requests. The use of this cmdlet and a typical output are shown here (for brevity, only File Server and BranchCache are shown in the output). In this example, File Server is installed and actively servicing client requests, and BranchCache is not.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-UalOverview<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">FirstSeen&nbsp;&nbsp; : 7\/14\/2012 11:41:21 AM<\/p>\n<p style=\"padding-left: 30px\">GUID&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: 10a9226f-50ee-49d8-a393-9a501d47ce04<\/p>\n<p style=\"padding-left: 30px\">LastSeen&nbsp;&nbsp; &nbsp;: 8\/18\/2012 10:41:01 PM<\/p>\n<p style=\"padding-left: 30px\">ProductName&nbsp; : Windows Server 2012 Datacenter<\/p>\n<p style=\"padding-left: 30px\">RoleName&nbsp;&nbsp; &nbsp;: File Server<\/p>\n<p style=\"padding-left: 30px\">PSComputerName :<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">FirstSeen&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">GUID&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: 910cbaf9-b612-4782-a21f-f7c75105434a<\/p>\n<p style=\"padding-left: 30px\">LastSeen&nbsp;&nbsp; &nbsp;:<\/p>\n<p style=\"padding-left: 30px\">ProductName&nbsp; : Windows Server 2012 Datacenter<\/p>\n<p style=\"padding-left: 30px\">RoleName&nbsp;&nbsp; &nbsp;: BranchCache<\/p>\n<p style=\"padding-left: 30px\">PSComputerName :<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&hellip;&hellip;&hellip;&hellip;<\/p>\n<p><b>Get-UalDeviceAccess<\/b> and <b>Get-UalUserAccess<\/b> output data that is centric to client users and client devices that are specific to server roles and applications. They provide first and last &ldquo;seen&rdquo; data per client. The use of these cmdlets and typical output is shown here. This example shows all the data that is unique to <b>testuser1<\/b>, and separately, all the data that is unique to <b>testuser2<\/b>.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-UalUserAccess &ndash;RoleName &ldquo;File Server&rdquo;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">ActivityCount&nbsp; : 18<\/p>\n<p style=\"padding-left: 30px\">FirstSeen&nbsp;&nbsp;&nbsp; : 7\/14\/2012 11:41:21 AM<\/p>\n<p style=\"padding-left: 30px\">LastSeen&nbsp;&nbsp;&nbsp; &nbsp;: 8\/18\/2012 10:41:00 PM<\/p>\n<p style=\"padding-left: 30px\">ProductName&nbsp;&nbsp; : Windows Server 2012 Datacenter<\/p>\n<p style=\"padding-left: 30px\">RoleGuid&nbsp;&nbsp;&nbsp; &nbsp;: 10a9226f-50ee-49d8-a393-9a501d47ce04<\/p>\n<p style=\"padding-left: 30px\">RoleName&nbsp;&nbsp;&nbsp; &nbsp;: File Server<\/p>\n<p style=\"padding-left: 30px\">TenantIdentifier : 00000000-0000-0000-0000-000000000000<\/p>\n<p style=\"padding-left: 30px\">UserName&nbsp;&nbsp;&nbsp; &nbsp;: testdomain\\testuser1<\/p>\n<p style=\"padding-left: 30px\">PSComputerName &nbsp;:<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">ActivityCount&nbsp; : 83<\/p>\n<p style=\"padding-left: 30px\">FirstSeen&nbsp;&nbsp;&nbsp; : 7\/14\/2012 11:51:11 AM<\/p>\n<p style=\"padding-left: 30px\">LastSeen&nbsp;&nbsp;&nbsp; &nbsp;: 8\/18\/2012 10:41:01 PM<\/p>\n<p style=\"padding-left: 30px\">ProductName&nbsp;&nbsp; : Windows Server 2012 Datacenter<\/p>\n<p style=\"padding-left: 30px\">RoleGuid&nbsp;&nbsp;&nbsp; &nbsp;: 10a9226f-50ee-49d8-a393-9a501d47ce04<\/p>\n<p style=\"padding-left: 30px\">RoleName&nbsp;&nbsp;&nbsp; &nbsp;: File Server<\/p>\n<p style=\"padding-left: 30px\">TenantIdentifier : 00000000-0000-0000-0000-000000000000<\/p>\n<p style=\"padding-left: 30px\">UserName&nbsp;&nbsp;&nbsp; &nbsp;: testdomain\\testuser2<\/p>\n<p style=\"padding-left: 30px\">PSComputerName &nbsp;:<\/p>\n<p>Although the Device and User &ldquo;Access&rdquo; cmdlets are paired with &ldquo;Daily&rdquo; versions, their intended use and output can be quite different. The &ldquo;Daily&rdquo; cmdlets, <b>Get-UalDailyUserAccess<\/b> and <b>Get-UalDailyDeviceAccess<\/b>, are provided to allow administrators to query a specific day or date range. To use these cmdlets to query a range, we must call into WMI from Windows PowerShell (for brevity, only the output for one user, on one day, is shown).<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; GWMI MsftUal_DailyUserAccess &ndash;ns root\\AccessLogging &ndash;filter &#8220;AccessDate &gt;= &#8216;7\/14\/2012&#8217; and AccessDate &lt;= &#8216;8\/15\/2012&#8242;&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">__GENUS&nbsp;&nbsp;&nbsp;&nbsp; : 2<\/p>\n<p style=\"padding-left: 30px\">__CLASS&nbsp;&nbsp;&nbsp;&nbsp; : MsftUal_DailyUserAccess<\/p>\n<p style=\"padding-left: 30px\">__SUPERCLASS&nbsp; &nbsp;:<\/p>\n<p style=\"padding-left: 30px\">__DYNASTY&nbsp;&nbsp;&nbsp; : MsftUal_DailyUserAccess<\/p>\n<p style=\"padding-left: 30px\">__RELPATH&nbsp;&nbsp;&nbsp; : MsftUal_DailyUserAccess.UserName=&#8221;testdomain\\\\testuser1&#8243;<\/p>\n<p style=\"padding-left: 30px\">__PROPERTY_COUNT : 6<\/p>\n<p style=\"padding-left: 30px\">__DERIVATION&nbsp; &nbsp;: {}<\/p>\n<p style=\"padding-left: 30px\">__SERVER&nbsp;&nbsp;&nbsp; &nbsp;: testcomputer<\/p>\n<p style=\"padding-left: 30px\">__NAMESPACE&nbsp;&nbsp; : root\\AccessLogging<\/p>\n<p style=\"padding-left: 30px\">__PATH&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: <a href=\"MsftUal_DailyUserAccess.UserName=%22testdomain\/testuser1\">\\\\testcomputer\\root\\AccessLogging:MsftUal_DailyUserAccess.UserName=&#8221;testdomain\\\\testuser1<\/a>&#8220;<\/p>\n<p style=\"padding-left: 30px\">AccessCount&nbsp;&nbsp; : 32<\/p>\n<p style=\"padding-left: 30px\">AccessDate&nbsp;&nbsp; &nbsp;: 20120714184121.000000+000<\/p>\n<p style=\"padding-left: 30px\">ProductName&nbsp;&nbsp; : Windows Server 2012 Datacenter<\/p>\n<p style=\"padding-left: 30px\">RoleGuid&nbsp;&nbsp;&nbsp; &nbsp;: 10a9226f-50ee-49d8-a393-9a501d47ce04<\/p>\n<p style=\"padding-left: 30px\">RoleName&nbsp;&nbsp;&nbsp; &nbsp;: File Server<\/p>\n<p style=\"padding-left: 30px\">UserName&nbsp;&nbsp;&nbsp; &nbsp;: testdomain\\testuser1<\/p>\n<p style=\"padding-left: 30px\">PSComputerName &nbsp;: testcomputer<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&hellip;&hellip;&hellip;&hellip;&hellip;<\/p>\n<p>UAL does not measure or expose the relative impact of any client activity or access on a system; however, for any role, an administrator could correlate this data with performance data for an infrastructure system and develop custom metrics that are specific to their environment.<\/p>\n<h3>Additional references<\/h3>\n<p>For more documentation about UAL, see the following topics in the Windows Server TechCenter:<\/p>\n<p><a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/hh849634\" target=\"_blank\">User Access Logging Overview<\/a><\/p>\n<p><a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/jj574126\" target=\"_blank\">Manage User Access Logging<\/a><\/p>\n<p><a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/jj618326\" target=\"_blank\">User Access Logging and Resulting Internet Communication in Windows Server 2012<\/a><\/p>\n<p>Also see the following topic in the Windows Dev Center:<\/p>\n<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/hh437528(v=vs.85).aspx\" target=\"_blank\">User Access Logging<\/a><\/p>\n<p>In addition, the Microsoft Assessment and Planning Toolkit enables you to consume, aggregate across a deployment of many servers, and generate reports of the data. To download this toolkit, see <a href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx\" target=\"_blank\">Microsoft Assessment and Planning Toolkit<\/a> in the Microsoft Download Center.<\/p>\n<p>~Brent<\/p>\n<p>Thank you, Brent! This is a way cool feature and a great explanation.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn about using Windows PowerShell to manage the new User Access Logging feature in Windows Server 2012. Microsoft Scripting Guy, Ed Wilson, is here. Today we have as our guest blogger, Brent Forman. Here is a little bit about Brent. Brent Forman is senior program manager in the Windows Server division at Microsoft. Brent [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[371,56,3,198,61,45,368],"class_list":["post-4963","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-brent-forman","tag-guest-blogger","tag-scripting-guy","tag-users","tag-weekend-scripter","tag-windows-powershell","tag-windows-server-2012"],"acf":[],"blog_post_summary":"<p>Summary: Learn about using Windows PowerShell to manage the new User Access Logging feature in Windows Server 2012. Microsoft Scripting Guy, Ed Wilson, is here. Today we have as our guest blogger, Brent Forman. Here is a little bit about Brent. Brent Forman is senior program manager in the Windows Server division at Microsoft. Brent [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=4963"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4963\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=4963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}