Powershell 4.0, sharepoint 2007 several general questions

I appreciate any help you can give me. I have been task with stripping out all list + attachments to those list from SharePoint 2007. I was told that powershell was the best if not only way to do this. I do not know anything about sharepoint and I’m a novice with powershell. question 1. Do I run the powershell script on the application server where sharepoint is installed or on the sql server where the database is stored? 2. Is there scripts all ready setup to do this? 3. I searched and found serveral scripts that indicate how to do it but I’m getting the following error.

PS H:> [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

PS H:> $site = New-Object Microsoft.SharePoint.SPSite(“http://sharepointit.???.org/TS/assetmgmt/SLAR/Forms/AllItems.aspx”)

New-Object : Cannot find type [Microsoft.SharePoint.SPSite]: verify that the assembly containing this type is loaded.

At line:1 char:9

  • $site = New-Object Microsoft.SharePoint.SPSite("http://sharepointit.???.org/TS …

  • 
    
  • CategoryInfo : InvalidType: (:slight_smile: [New-Object], PSArgumentException

  • FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

 

Hi,

You need to run it on the application server and not on the SQL server. You’re just missing a prerequisite, which is loading the required .DLLs into your console session. Try running these lines first:

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | Out-Null
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | Out-Null
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | Out-Null
[System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null

And you only need the URL of the site, not the page or the document library.

When you’ve the $site variable, you can continue getting the lists/libraries and files using other examples from the internet