none
SharePoint Last change on the site. RRS feed

  • Question

  • Hello.
    I have a SharePoint 2016.
    please tell me how through powershell on 1 site to show all the changes that occurred after a certain date. (after 06.22.19) export to Excel?
    Friday, September 27, 2019 4:02 PM

Answers

  • Hi,

    You could try the following script:

    $web=get-spweb http://sp16/sites/test/
    $data=@()
    $date=[datetime]("6/22/2019")
    foreach($list in $web.lists){
    	foreach($item in $list.items){
    		if($item['Modified'] -gt $date){
    			$ExportItem = New-Object PSObject
    			$ExportItem | Add-Member -MemberType NoteProperty -name "ListTitle" -value $list.Title
     			$ExportItem | Add-Member -MemberType NoteProperty -name "Item" -value $item.url
    			$ExportItem | Add-Member -MemberType NoteProperty -name "Modified" -value $item["Modified"]
     			$ExportItem | Add-Member -MemberType NoteProperty -name "ModifiedBy" -value $item["Modified By"]
    			$data+=$ExportItem
    		}
    	}
    }
    $data | Export-CSV "c:\ListData.csv" -NoTypeInformation

    It may takes some time to run the powershell.

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by PiligrimKa Monday, September 30, 2019 2:56 PM
    Monday, September 30, 2019 5:14 AM
  • Hi PiligrimKa,

    Sorry for the late reply. To use spQuery, here is a demo for you:

    $web=get-spweb http://sp16/sites/test/
    $query = New-Object Microsoft.SharePoint.SPQuery;
    $query.Query = "   <Where>
          <Gt>
             <FieldRef Name='Modified' />
             <Value Type='DateTime'>2019-06-22T12:00:00Z</Value>
          </Gt>
       </Where>";
    foreach($list in $web.lists){  
    $items=$list.GetItems($query)
    $items | Select @{ L = "Item"; E = { $_.url } }, @{ L = "Modified"; E = { $_["Modified"] } } , @{ L = "ModifiedBy"; E = { $_["Modified By"] } } | Export-Csv -Path c:\export.csv -Append
    }

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by PiligrimKa Friday, October 4, 2019 9:28 AM
    Friday, October 4, 2019 7:31 AM
  • Hi PiligrimKa,

    Thanks for marking my reply as answer. I’m pleased to know that the information is helpful to you. 

    Here I will provide a brief summary of this post for your information.

    Issue Symptom:

    Use spQuery to list all the changes that occurred after a certain date and export to Excel through powershell 

    Solution:

    Use the following powershell to achieve this:

    $web=get-spweb http://sp16/sites/test/
    $query = New-Object Microsoft.SharePoint.SPQuery;
    $query.Query = "   <Where>
          <Gt>
             <FieldRef Name='Modified' />
             <Value Type='DateTime'>2019-06-22T12:00:00Z</Value>
          </Gt>
       </Where>";
    foreach($list in $web.lists){  
    $items=$list.GetItems($query)
    $items | Select @{ L = "Item"; E = { $_.url } }, @{ L = "Modified"; E = { $_["Modified"] } } , @{ L = "ModifiedBy"; E = { $_["Modified By"] } } | Export-Csv -Path c:\export.csv -Append
    }

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by PiligrimKa Friday, November 22, 2019 6:38 AM
    Monday, October 7, 2019 2:58 AM

All replies

  • Add SharePoint modules and create variable space
    add-pssnapin microsoft.sharepoint.powershell
    start-spassignment -global
    
    #Open the web site, list and the workflow
    $site=get-spsite https://mysite.com
    $web=get-spweb https://mysite.com/myweb/
    
    #Open the %affected% library or list and workflow association
    
    $affected=$web.getlist("Practical Tips")
    
    #Start workflow
    foreach ($item in $affected.items) {
    $item["Modified"]
    }
    
    
    $csvObjects = import-csv $file 
    $NewCSVObject = @()  
    foreach ($item in $affected.items) { 
    {  
        $NewCSVObject += $item | Add-Member -name $item["Title"]-value $item["Modified"] -MemberType NoteProperty  
    }  
    $NewCSVObject | export-csv $File -noType 
    Please check the above script .

    Please remember to click Mark as Answer on the answer if it helps you

    Friday, September 27, 2019 5:36 PM
  • Hi Piligrim,

    Are you interested to know the changes on a specific list or all the lists in the site including permissions?

    Regards,

    Krishna

    Friday, September 27, 2019 5:57 PM
  • Good afternoon. On the site I need, there are document libraries (it has a large nesting of folders), there are also lists.
    I need to display information where, by whom, when changes were made to document libraries and lists.

    In the last two months.


    • Edited by PiligrimKa Saturday, September 28, 2019 12:57 PM
    Saturday, September 28, 2019 12:10 PM
  • This script does not work, writes an error

    Saturday, September 28, 2019 12:56 PM
  • Hi,

    You could try the following script:

    $web=get-spweb http://sp16/sites/test/
    $data=@()
    $date=[datetime]("6/22/2019")
    foreach($list in $web.lists){
    	foreach($item in $list.items){
    		if($item['Modified'] -gt $date){
    			$ExportItem = New-Object PSObject
    			$ExportItem | Add-Member -MemberType NoteProperty -name "ListTitle" -value $list.Title
     			$ExportItem | Add-Member -MemberType NoteProperty -name "Item" -value $item.url
    			$ExportItem | Add-Member -MemberType NoteProperty -name "Modified" -value $item["Modified"]
     			$ExportItem | Add-Member -MemberType NoteProperty -name "ModifiedBy" -value $item["Modified By"]
    			$data+=$ExportItem
    		}
    	}
    }
    $data | Export-CSV "c:\ListData.csv" -NoTypeInformation

    It may takes some time to run the powershell.

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by PiligrimKa Monday, September 30, 2019 2:56 PM
    Monday, September 30, 2019 5:14 AM
  • Hi,

    You could try the following script:

    $web=get-spweb http://sp16/sites/test/
    $data=@()
    $date=[datetime]("6/22/2019")
    foreach($list in $web.lists){
    	foreach($item in $list.items){
    		if($item['Modified'] -gt $date){
    			$ExportItem = New-Object PSObject
    			$ExportItem | Add-Member -MemberType NoteProperty -name "ListTitle" -value $list.Title
     			$ExportItem | Add-Member -MemberType NoteProperty -name "Item" -value $item.url
    			$ExportItem | Add-Member -MemberType NoteProperty -name "Modified" -value $item["Modified"]
     			$ExportItem | Add-Member -MemberType NoteProperty -name "ModifiedBy" -value $item["Modified By"]
    			$data+=$ExportItem
    		}
    	}
    }
    $data | Export-CSV "c:\ListData.csv" -NoTypeInformation

    It may takes some time to run the powershell.

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thank you very much this code works.
    Could you tell me how to write the same thing correctly, but use spQuery, not foreach.
    I would be very grateful if you help.
    Tuesday, October 1, 2019 12:56 PM
  • Hi PiligrimKa,

    Sorry for the late reply. To use spQuery, here is a demo for you:

    $web=get-spweb http://sp16/sites/test/
    $query = New-Object Microsoft.SharePoint.SPQuery;
    $query.Query = "   <Where>
          <Gt>
             <FieldRef Name='Modified' />
             <Value Type='DateTime'>2019-06-22T12:00:00Z</Value>
          </Gt>
       </Where>";
    foreach($list in $web.lists){  
    $items=$list.GetItems($query)
    $items | Select @{ L = "Item"; E = { $_.url } }, @{ L = "Modified"; E = { $_["Modified"] } } , @{ L = "ModifiedBy"; E = { $_["Modified By"] } } | Export-Csv -Path c:\export.csv -Append
    }

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by PiligrimKa Friday, October 4, 2019 9:28 AM
    Friday, October 4, 2019 7:31 AM
  • Hi PiligrimKa,

    Thanks for marking my reply as answer. I’m pleased to know that the information is helpful to you. 

    Here I will provide a brief summary of this post for your information.

    Issue Symptom:

    Use spQuery to list all the changes that occurred after a certain date and export to Excel through powershell 

    Solution:

    Use the following powershell to achieve this:

    $web=get-spweb http://sp16/sites/test/
    $query = New-Object Microsoft.SharePoint.SPQuery;
    $query.Query = "   <Where>
          <Gt>
             <FieldRef Name='Modified' />
             <Value Type='DateTime'>2019-06-22T12:00:00Z</Value>
          </Gt>
       </Where>";
    foreach($list in $web.lists){  
    $items=$list.GetItems($query)
    $items | Select @{ L = "Item"; E = { $_.url } }, @{ L = "Modified"; E = { $_["Modified"] } } , @{ L = "ModifiedBy"; E = { $_["Modified By"] } } | Export-Csv -Path c:\export.csv -Append
    }

    Best Regards,

    Michael Han


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by PiligrimKa Friday, November 22, 2019 6:38 AM
    Monday, October 7, 2019 2:58 AM
  • add to this list a full link where the changes were made))
    Friday, November 22, 2019 6:38 AM