SharePoint 2010: Get the Created and Modified date of an SPView using PowerShell
Introduction
The following file information, Created, Created By, Modified, Modify By, cannot be accessed directly via the SPView object. The SPView object doesn't provide these properties. Use the SPFile object to access these properties.
- "Created by" matches SPFile.Author
- "Created" matches SPFile.TimeCreated
- "Modified" matches SPFile.LastTimeModifed
- "Modified by" matches SPFile.ModifiedBy
Getting the Information using PowerShell
The following PowerShell script can be used to retrieve these properties:
# define variables for script
$SiteUrl = "http://yourserver/sites/yoursite"
$viewurl = "http://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"
}
}
See Also
An important place to find a huge amount of SharePoint related articles is the TechNet Wiki itself. The best entry point is SharePoint Resources on the TechNet Wiki
References
- Reference Forum: Need to know who created a view in a list using powershell
- Download the script from the TechNet Gallery: http://gallery.technet.microsoft.com/Advanced-Information-View-a96f2b15
Other languages
This article is also available in the following languages :