Get creation and modification Information from Views in Lists and Libraries using PowerShell
- Updated:
The “Modified”, “Modified By”, “Created by”, “Created” cannot be accessed directly via the SPView object because this simply doesn’t store that kind of information. To request this information the SPFile object needs to be used instead.
- “Created by” matches SPFile.Author
- “Created” matches SPFile.TimeCreated
- “Modified” matches SPFile.LastTimeModifed
- “Modified by” matches SPFile.ModifiedBy
To get this information the following power shell script can be used:
# define variables for script
$SiteUrl = "https://yourserver/sites/yoursite"
$viewurl = "https://yourserver/sites/yoursite/Lists/customlist/AllItems.aspx"
$targetUrl = Get-SPWeb -Identity $SiteUrl
if ($targetUrl -ne $null)
{
$targetFile = $targetUrl.GetFile($viewurl)
if($targetFile.Exists)
{
Write-Host "Created By: " $targetFile.Author
Write-Host "Modified: " $targetFile.TimeLastModified
Write-Host "Modified By: " $targetFile.ModifiedBy
Write-Host "Created: " $targetFile.TimeCreated
}
else
{
Write-Host "File doesn't exist"
}
}