3

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue; $spSite=Get-SPSite -Identity "http://sp/sites/dev" $spwWeb=$spSite.OpenWeb() $spAuditQuery=New-Object Microsoft.SharePoint.SPAuditQuery($spSite) $Today = [DateTime]::Today $DateLimit = $Today.AddDays(-7) $spAuditQuery.SetRangeStart($DateLimit) $...


2

The issue is related to this line dRow["NewColumn"] = entry.MachineName; where the entry.MachineName returns as NULL. (Debugged on my side) Unfortunately, By Design the returned values of the MachineName and MachineIP are always NULL for Privacy concerns. Besides the above issue, There is a bit syntax issue related to this line DataRow dRow = dtAudit....


1

Try this: using (SPSite mysiteCollection = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb oWeb = mysiteCollection.OpenWeb()) { SPAuditQuery query = new SPAuditQuery(mysiteCollection); query.SetRangeStart(DateTime.Now.AddDays(-1)); query.SetRangeEnd(DateTime.Now); ...


Only top voted, non community-wiki answers of a minimum length are eligible