C:\iislogs\logparser.exe
-
i:W3C
"select cs-username as User, Count(*) as ReadCount, date into report.csv from .\* where cs-uri-stem = '/marketing/documents/myspecialdocument.pdf' and User Is Not Null and date > Timestamp('2013-07-09','yyyy-MM-dd') group by user,date"
o:CSV
$request = New-Object psobject
$request | Add-Member -MemberType NoteProperty -Name
"Name"
-value
""
"Location"
"Department"
"EmployeeType"
"Reads"
$r = Import-Csv .\report.csv
$a = $
null
;
$a = @();
foreach
($i
in
$r)
$i.User.Substring($i.User.IndexOf(
'\'
)+1)
$u =
get
-aduser $i.User.Substring($i.User.IndexOf(
)+1) -Properties displayName,department,office,employeeType
if
($u -ne
){
$b = $request | Select-Object *;
$b.Name = $u.displayName;
$b.Location = $u.office;
$b.Department = $u.department;
$b.EmployeeType = $u.employeeType;
$b.Reads = $i.ReadCount;
$a += $b;
;}
$a = @()
$r){$u=
;$u =
)+1) -Properties displayName,department,office,employeeType -ErrorAction:SilentlyContinue;
$b = $request | Select-Object *; $b.Name = $u.displayName; $b.Location = $u.office; $b.Department = $u.department; $b.EmployeeType = $u.employeeType; $b.Reads = $i.ReadCount; $a += $b;
;}}
$nr = @();
$nr +=
"Total Count: "
+$a.Count
"Count per office:"
$b = $a | group location;
($d
$b){$nr += $d.Count.ToString()+
"`t"
+$d.Name}
"Total Partners"
$b = $a | ?{$_.Department -like
"Partners"
} | measure;
"Partners / Office"
} | group location;
"Total Support Staff"
$b = $a | ?{$_.EmployeeType -like
"SupportStaff"
"Support Staff / Office"
"Total Fee Earning Staff"
"FeeEarningStaff"
"Fee Earning Staff / Office"
Naomi N edited Revision 3. Comment: Minor edit
Matthew Yarlett edited Original. Comment: Altered examples, fixed spelling/grammar mistakes
Matthew, can you add tag "candidate for deletion" to this article? social.technet.microsoft.com/.../19030.sharepoint-using-logparser-and-powershell-to-create-quick-analytic-reports.aspx. I think it was created by mistake.