Need help with powershell and sharepoint 2007 on 2008 windows server

I know very little powershell but I’ve been nominated to extract all attachments from our 2007 sharepoint server before it gets shut down. I’m trying to run the script below but keep getting errors on the new-object Microsoft.sharepoint.spsite

I PS H:\> $webUrl = New-Object Microsoft.SharePoint.spsite (“http://mysite”)New-Object : Cannot find type [Microsoft.SharePoint.spsite]: verify that the assembly containing this type is loaded.


$webUrl = New-Object Microsoft.SharePoint.spsite (“http://mysite ”)
$library = "Technology Services (TS)" $tempLocation = "D:\transfer\Attachments" $s = new-object Microsoft.SharePoint.SPSite($webUrl) $web = $site.OpenWeb() $l = $w.Lists[$library]

foreach ($listItem in $l.Items)
Write-Host " Content: " $listItem.ID
$destinationfolder = $tempLocation + “” + $listItem.ID
if($listItem.Attachments.Count -gt 0)
if (!(Test-Path -path $destinationfolder))
$dest = New-Item $destinationfolder -type directory
foreach ($attachment in $listItem.Attachments)
$file = $w.GetFile($listItem.Attachments.UrlPrefix + $attachment)
$bytes = $file.OpenBinary()
$path = $destinationfolder + “” + $attachment
Write “Saving $path”
$fs = new-object System.IO.FileStream($path, “OpenOrCreate”)
$fs.Write($bytes, 0 , $bytes.Length)

Sorry if this is a dumb question, but you are running the script on the SP server itself and or have it setup for SharePoint remoting?